Example #1
0
 private void _OnConnect(TcpClientSocket tcpSocket)
 {
     if (this.OnConnect != null)
     {
         this.OnConnect(this);
     }
 }
Example #2
0
 public SprotoTcpSocket(SprotoMgr S2C, SprotoMgr C2S)
 {
     this.TcpSocket = new TcpClientSocket();
     this.TcpSocket.Register(this._OnConnect, this._OnClose, this._OnMessage, this._Log);
     this.Dispatcher = new ProtoDispatcher();
     this.Proto      = new SprotoRpc(S2C, C2S);
 }
Example #3
0
 private void _OnClose(TcpClientSocket tcpSocket)
 {
     if (this.OnClose != null)
     {
         this.OnClose(this);
     }
 }
Example #4
0
        public SprotoTcpSocket(string s2cfile, string c2sfile, bool isbinary = false)
        {
            this.TcpSocket = new TcpClientSocket();
            this.TcpSocket.Register(this._OnConnect, this._OnClose, this._OnMessage, this._Log);
            this.Dispatcher = new ProtoDispatcher();
            SprotoMgr S2C = SprotoParser.ParseFile(s2cfile);
            SprotoMgr C2S = SprotoParser.ParseFile(c2sfile);

            this.Proto = new SprotoRpc(S2C, C2S);
        }
Example #5
0
        private void _OnMessage(TcpClientSocket tcpSocket, byte[] data, int size)
        {
            RpcMessage Message = this.Proto.UnpackMessage(data, size);
            string     msg     = String.Format("[{0}] op=OnMessage,proto={1},tag={2},ud={3},session={4},type={5},request={6},response={7}",
                                               this.TcpSocket.Name, Message.proto, Message.tag, Message.ud, Message.session, Message.type, Message.request, Message.response);

            this._Log(msg);
            if (Message.type == "response")
            {
                Int64 session = Message.session;
                ProtoDispatcher.MessageHandler handler = null;
                if (!this.sessions.TryGetValue(session, out handler))
                {
                    return;
                }
                handler(this, Message);
                return;
            }
            this.Dispatcher.Dispatch(this, Message);
        }