Esempio n. 1
0
        private void SocketData(int source, int session, string method, byte[] param)
        {
            NetSprotoType.SocketData socketData = new NetSprotoType.SocketData(param);
            long connectionId = socketData.connection;
            byte[] tempParam = Convert.FromBase64String(socketData.buffer);

            SkynetClusterRequest req = m_skynetPacketManager.UnpackSkynetRequest(tempParam);
            if (req == null)
            {
                return;
            }

            NetProtocol instance = NetProtocol.GetInstance();
            int tag = instance.GetTag("RPC");
            RPCParam sprotoRequest = (RPCParam)instance.Protocol.GenRequest(tag, req.Data);
            byte[] targetParam = Convert.FromBase64String(sprotoRequest.param);

            if (req.Session > 0)
            {
                SSContext context = new SSContext();
                context.IntegerDict["RemoteSession"] = req.Session;
                context.LongDict["ConnectionId"] = connectionId;

                Call(req.ServiceName, sprotoRequest.method, targetParam, context, TransferCallback);
            }
            else
            {
                Send(req.ServiceName, sprotoRequest.method, targetParam);
            }
        }
Esempio n. 2
0
        private void OnError(Message msg)
        {
            NetProtocol instance = NetProtocol.GetInstance();
            int         tag      = instance.GetTag("Error");

            Error.response sprotoError = (Error.response)instance.Protocol.GenResponse(tag, msg.Data);

            RPCResponseContext responseCallback = null;
            bool isExist = m_responseCallbacks.TryGetValue(msg.RPCSession, out responseCallback);

            if (isExist)
            {
                responseCallback.Callback(responseCallback.Context, msg.Method, Encoding.ASCII.GetBytes(sprotoError.errorText), (RPCError)sprotoError.errorCode);
                m_responseCallbacks.Remove(msg.RPCSession);
            }
            else
            {
                LoggerHelper.Info(m_serviceAddress, string.Format("Service:{0} session:{1} get error:{2}; error text is {3}",
                                                                  m_serviceAddress, msg.RPCSession, sprotoError.errorCode, sprotoError.errorText));
            }
        }