コード例 #1
0
        public void SendMessage <T>(T m)
        {
            string s = typeof(T).FullName;
            int    t;
            bool   b = cdict.TryGetValue(s, out t);

            if (b)
            {
                Stream str = new MemoryStream();
                Serializer.Serialize <T>(str, m);
                string tname = typeof(T).Name;
                switch (tname[0])
                {
                case 'C':
                    socketManager.SendProtoMessage(SocketId.Main, t, str);
                    break;

                case 'R':
                    socketManager.SendProtoMessage(SocketId.Chat, t, str);
                    break;

                default:
                    break;
                }
                HDebugger.Log(HDebuggerModule.Proto, "SendMessage all network log : C --> S : " + s);
            }
        }
コード例 #2
0
        public void SendMessageEmpty <T>()
        {
            string s = typeof(T).FullName;
            int    t;
            bool   b = cdict.TryGetValue(s, out t);

            if (b)
            {
                string tname = typeof(T).Name;
                switch (tname[0])
                {
                case 'C':
                    socketManager.SendEmptyMessage(SocketId.Main, t);
                    HDebugger.Log(HDebuggerModule.Proto, "C --> S : " + s);
                    break;

                case 'R':
                    socketManager.SendEmptyMessage(SocketId.Chat, t);
                    break;

                default:
                    break;
                }
            }
        }
コード例 #3
0
        public void SendMessage <T>(SocketId socketId, T m)
        {
            string s = typeof(T).FullName;
            int    t;
            bool   b = cdict.TryGetValue(s, out t);

            if (b)
            {
                Stream str = new MemoryStream();
                Serializer.Serialize <T>(str, m);
                string tname = typeof(T).Name;

                socketManager.SendProtoMessage(socketId, t, str);
                HDebugger.Log(HDebuggerModule.Proto, "SendMessage network log : C --> S : " + s);
            }
        }
コード例 #4
0
        protected bool Send(byte[] buffer, int offset, int size)
        {
            if (socket.Connected)
            {
                SocketError sr;
                int         i = socket.Send(buffer, offset, size, SocketFlags.None, out sr);

                if (i == -1 || sr != SocketError.Success)
                {
                    HDebugger.Log(HDebuggerModule.Proto, sr.ToString());
                    Reconnect();
                    return(false);
                }
                return(true);
            }
            return(false);
        }