예제 #1
0
        protected void Send(MyMethodDefinition method, IMessage message)
        {
            MyRpcRequest req = new MyRpcRequest();

            req.RequestId   = 0;
            req.MethodId    = method.MethodId;
            req.ServiceId   = this.ServiceId;
            req.PayloadData = message.ToByteString();
            m_Canal.Send(req);
        }
예제 #2
0
파일: MyServer.cs 프로젝트: bazoocaze/CsFun
        private void OnPacketReceived(SimpleClient sender, ByteStream packetStream)
        {
            MyRpcRequest req = new MyRpcRequest();

            req.MergeFrom(new CodedInputStream(packetStream));

            MyServiceDefinition service;

            if (m_Services.TryGetValue(req.ServiceId, out service))
            {
                service.OnRequestReceived(sender, req);
            }
        }
예제 #3
0
        private void OnPacketReceived(SimpleClient sender, ByteStream packetStream)
        {
            MyRpcRequest req = new MyRpcRequest();

            req.MergeFrom(packetStream);
            MyRequestHandler pending;

            if (m_PendingRequests.TryGetValue(req.RequestId, out pending))
            {
                pending.OnResponse(req);
                if (pending.Concluido)
                {
                    m_PendingRequests.Remove(req.RequestId);
                }
            }
        }
예제 #4
0
        public void OnRequestReceived(SimpleClient sender, MyRpcRequest req)
        {
            MyMethodDefinition method;

            if (m_Methods.TryGetValue(req.MethodId, out method))
            {
                IMessage result = method.OnRequest(req.PayloadData);
                if (result != null)
                {
                    MyRpcRequest response = new MyRpcRequest();
                    response.ServiceId   = req.ServiceId;
                    response.MethodId    = req.MethodId;
                    response.RequestId   = req.RequestId;
                    response.PayloadData = result.ToByteString();

                    sender.Send(response);
                }
            }
        }
예제 #5
0
 public virtual void OnResponse(MyRpcRequest request)
 {
     throw new NotImplementedException();
 }