Package com.guxuede.mina.chat

Source Code of com.guxuede.mina.chat.ChatPro

package com.guxuede.mina.chat;

import java.util.HashMap;

import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;

import com.guxuede.mina.bean.HttpMessage;

public class ChatPro {

  public static void chatSessionLeave(IoSession session){
    ChatHall.leaveRoom(session);
  }
 
  public static void chatSessionReceived(HttpMessage request,IoSession session){
    HashMap<String,String> data=request.data;
    String opt=data.get("opt");
    if(opt!=null && opt.equalsIgnoreCase("join")){
      ChatHall.joinRoom(session);
      ChatRoom.speakTo("<comet>Hello,welcome to join!</comet>", session);
    }else if(opt!=null && opt.equalsIgnoreCase("send")){
      String msg=data.get("msg");
      String nick=data.get("nick")+":";
      if(msg!=null){
        ChatHall.speakAll(0L, "<comet>"+nick+msg+"</comet>");
      }
      session.close(false);
    }
    else{
      session.close(false);
    }
  }
 
  public static void main(String[] args) {
    IoBuffer buf=IoBuffer.allocate(10);
    buf.putChar('i');
    System.out.println(buf);
    buf.rewind();
    System.out.println(buf);
  }
}
TOP

Related Classes of com.guxuede.mina.chat.ChatPro

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.