Example #1
0
        public static byte[] Pack(int actionId, BaseReqData data)
        {
            var head = new PackageReqHead()
            {
                ActionId = actionId, MsgId = ++MsgCounter
            };

            WriteHead(head);
            WriteData(data);

            Console.WriteLine("Send: {0}", _sendStr);
            var bytes = WriteBytesLength();

            _sendStr = "";
            return(bytes);
        }
Example #2
0
        public static byte[] Pack <T>(int actionId, BaseReqData data, Action <T> callback) where T : BaseResData
        {
            var head = new PackageReqHead()
            {
                ActionId = actionId, MsgId = ++MsgCounter,
                callback = (res) =>
                {
                    var obj = JsonMapper.ToObject <T>(res);
                    callback(obj);
                }
            };

            SocketClient.SendDic.Add(head.MsgId, head);
            WriteHead(head);
            WriteData(data);

            Console.WriteLine("Send: {0}", _sendStr);
            var bytes = WriteBytesLength();

            _sendStr = "";
            return(bytes);
        }
Example #3
0
 private static void WriteHead(PackageReqHead head)
 {
     _sendStr += string.Format(
         "MsgId={0}&ActionId={1}&Sid={2}&Uid={3}",
         head.MsgId, head.ActionId, PackageReqHead.SessionId, PackageReqHead.UserId);
 }