示例#1
0
        /// <summary>

        /**
         * 注意:  此函数需在主线程调用(luaMgr.CallLuaFunction)
         * 返回值表示:lua是否能完全处理该协议
         * 返回false,会继续交给c#处理此协议.
         * 返回true,表示不再交给c#处理此协议.
         * 在具体项目中此处的返回值由lua决定.
         */
        /// </summary>
        static internal bool handleMsg(int msgType, byte[] buff, int packetSize, int offset)
        {
            //通知lua进行处理
            if (IsLuaProtocol(msgType))
            {
                int    headSize = 12;
                byte[] message  = new byte[packetSize];
                for (int i = 0; i < packetSize - headSize; i++)
                {
                    message[i] = buff[headSize + offset + i];
                }
                //异步通知到socketCommand再调用lua方法
                RazByteBuffer data = new RazByteBuffer(message);
                GetLuaManager().CallLuaFunction <int, RazByteBuffer>("Network.OnSocket", msgType, data);
                return(true);
            }
            return(false);
        }
示例#2
0
 /// <summary>
 /// 发送SOCKET消息
 /// </summary>
 public void SendMessage(RazByteBuffer buffer, string socket_type)
 {
     if (socket_type == "local")
     {
         LocalSocketManager.Instance.sendMsg(buffer.ToBytes());
     }
     else if (socket_type == "login")
     {
         LoginSocketManager.Instance.sendMsg(buffer.ToBytes());
     }
     else if (socket_type == "chat")
     {
         ChatSocketManager.Instance.sendMsg(buffer.ToBytes());
     }
     else if (socket_type == "game")
     {
         GameSocketManager.Instance.sendMsg(buffer.ToBytes());
     }
     else if (socket_type == "pvp")
     {
         PVPSocketManager.Instance.sendMsg(buffer.ToBytes());
     }
 }
示例#3
0
 ///------------------------------------------------------------------------------------
 public static void AddEvent(int _event, RazByteBuffer data)
 {
     lock (m_lockObject) {
         mEvents.Enqueue(new KeyValuePair <int, RazByteBuffer>(_event, data));
     }
 }