Package com.jason.server.ws

Source Code of com.jason.server.ws.WebSocketProcesser

/**
* <li>文件名:AdProcesser.java
* <li>说明:
* <li>创建人:CshBBrain;技术博客:http://cshbbrain.iteye.com/
* <li>创建日期:2011-11-18
* <li>修改人:
* <li>修改日期:
*/
package com.jason.server.ws;

import java.util.HashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.jason.server.Response;
import com.jason.server.Client;
import com.jason.server.hander.ProcessHandler;
import com.jason.server.ws.biz.Constants;
import com.jason.server.ws.biz.Service;

/**
*
* * <pre>
* version 5-->
*    0                   1                   2                   3
*    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
*   +-+-+-+-+-------+-+-------------+-------------------------------+
*   |F|R|R|R| opcode|M| Payload len |    Extended payload length    |
*   |I|S|S|S|  (4)  |A|     (7)     |             (16/63)           |
*   |N|V|V|V|       |S|             |   (if payload len==126/127)   |
*   | |1|2|3|       |K|             |                               |
*   +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
*   |     Extended payload length continued, if payload len == 127  |
*   + - - - - - - - - - - - - - - - +-------------------------------+
*   |                               |Masking-key, if MASK set to 1  |
*   +-------------------------------+-------------------------------+
*   | Masking-key (continued)       |          Payload Data         |
*   +-------------------------------- - - - - - - - - - - - - - - - +
*   :                     Payload Data continued ...                :
*   + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
*   |                     Payload Data continued ...                |
*   +---------------------------------------------------------------+
*   version 1--------4
*    0                   1                   2                   3
*    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
*   +-+-+-+-+-------+-+-------------+-------------------------------+
*   |M|R|R|R| opcode|R| Payload len |    Extended payload length    |
*   |O|S|S|S|  (4)  |S|     (7)     |             (16/63)           |
*   |R|V|V|V|       |V|             |   (if payload len==126/127)   |
*   |E|1|2|3|       |4|             |                               |
*   +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
*   |     Extended payload length continued, if payload len == 127  |
*   + - - - - - - - - - - - - - - - +-------------------------------+
*   |                               |         Extension data        |
*   +-------------------------------+ - - - - - - - - - - - - - - - +
*   :                                                               :
*   +---------------------------------------------------------------+
*   :                       Application data                        :
*   +---------------------------------------------------------------+
*
* </pre>
* <li>类型名称:
* <li>说明:
* <li>创建人:CshBBrain;技术博客:http://cshbbrain.iteye.com/
* <li>创建日期:2011-11-18
* <li>修改人:
* <li>修改日期:
*/
public class WebSocketProcesser extends ProcessHandler {
  private static Log log = LogFactory.getLog(WebSocketProcesser.class);// 日志记录器
  public void process(Client sockector){
    ConcurrentLinkedQueue<HashMap<String,String>> msgs = sockector.getBizObjects();
    if(msgs.isEmpty()){
      return;
    }
   
    HashMap<String,String> msg = msgs.poll();
    while(msg != null){
      msg.put(Constants.FILED_IP, sockector.getIp());
      Response rm = Service.getInstance().service(sockector,msg);
      if(rm != null){
        rm.setRequestIndex(msg.get(WebSocketConstants.REQUEST_INDEX));// 设置请求索引数
        sockector.addResponseMsg(rm);
      }
     
      msg = msgs.poll();
    }
  }

}
TOP

Related Classes of com.jason.server.ws.WebSocketProcesser

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.