Beispiel #1
0
        /// <summary>
        /// 发送本地客户端帧信息
        /// </summary>
        protected void SendClientFrame(object sender, ElapsedEventArgs e)
        {
            if (client.ServerCon.clientId < 0)
            {
                return;
            }
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Frame);
            protocol.push((byte)client.ServerCon.clientId);

            foreach (var bt in sendKey.GetBytes())
            {
                protocol.push(bt);
            }



            protocol.push((byte)joySticks.Count);
            // Debug.LogError("len"+joySticks.Count);
            foreach (var joy in joySticks)
            {
                //  Debug.LogError("key"+joy.Key);
                protocol.push((byte)joy.Key);
                protocol.push(joy.Value.direction);
            }

            client.Send(protocol.GetByteStream());
        }
Beispiel #2
0
        public static Byte[] Serialize(Action <ByteProtocol> serialize)
        {
            var pro = new ByteProtocol();

            serialize(pro);
            return(pro.GetByteStream());
        }
        private void SendPingMsg()
        {
            m_dtLastPingTime = DateTime.Now;
            ProtocolBase protocol = new ByteProtocol();

            protocol.push((byte)MessageType.Ping);
            protocol.push((byte)ServerCon.clientId);
            this.Send(protocol.GetByteStream());
        }