예제 #1
0
파일: Session.cs 프로젝트: xushouqi/ET
        public void Send(byte flag, ushort opcode, byte[] bytes)
        {
            if (this.IsDisposed)
            {
                throw new Exception("session已经被Dispose了");
            }
            this.byteses[0][0] = flag;
            this.byteses[1]    = BitConverter.GetBytes(opcode);
            this.byteses[2]    = bytes;

#if SERVER
            // 如果是allserver,内部消息不走网络,直接转给session,方便调试时看到整体堆栈
            if (this.Network.AppType == AppType.AllServer)
            {
                Session session = this.Network.Entity.GetComponent <NetInnerComponent>().Get(this.RemoteAddress);
                this.pkt.Length = 0;
                ushort index = 0;
                foreach (var byts in byteses)
                {
                    Array.Copy(byts, 0, this.pkt.Bytes, index, byts.Length);
                    index += (ushort)byts.Length;
                }

                this.pkt.Length = index;
                this.pkt.Flag   = flag;
                this.pkt.Opcode = opcode;
                session.Run(this.pkt);
                return;
            }
#endif

            channel.Send(this.byteses);
        }
예제 #2
0
        public void Send(byte flag, ushort opcode, byte[] bytes)
        {
            if (this.IsDisposed)
            {
                throw new Exception("session已经被Dispose了");
            }
            this.byteses[0][0] = flag;
            this.byteses[1]    = BitConverter.GetBytes(opcode);
            this.byteses[2]    = bytes;

#if SERVER
            // 如果是allserver,内部消息不走网络,直接转给session,方便调试时看到整体堆栈
            if (this.Network.AppType == AppType.AllServer)
            {
                Session session = this.Network.Entity.GetComponent <NetInnerComponent>().Get(this.RemoteAddress);

                Packet packet = ((TChannel)this.channel).parser.packet;

                Array.Copy(bytes, 0, packet.Bytes, 0, bytes.Length);

                packet.Offset = 0;
                packet.Length = (ushort)bytes.Length;
                packet.Flag   = flag;
                packet.Opcode = opcode;
                session.Run(packet);
                return;
            }
#endif

            channel.Send(this.byteses);
        }
예제 #3
0
파일: Session.cs 프로젝트: superzys/ET
        public void Send(byte flag, ushort opcode, object message)
        {
            if (this.IsDisposed)
            {
                throw new Exception("session已经被Dispose了");
            }
            this.byteses[0][0] = flag;
            this.byteses[1]    = BitConverter.GetBytes(opcode);

#if SERVER
            // 如果是allserver,内部消息不走网络,直接转给session,方便调试时看到整体堆栈
            if (this.Network.AppType == AppType.AllServer)
            {
                Session session = this.Network.Entity.GetComponent <NetInnerComponent>().Get(this.RemoteAddress);

                Packet packet = ((TChannel)this.channel).parser.packet;

                packet.Flag   = flag;
                packet.Opcode = opcode;
                session.Run(packet);
                return;
            }
#endif

            MemoryStream stream = this.channel.GetPacket().Stream;
            stream.Write(this.byteses[0], 0, this.byteses[0].Length);
            stream.Write(this.byteses[1], 0, this.byteses[1].Length);
            stream.Seek(Packet.Index, SeekOrigin.Begin);
            stream.SetLength(Packet.Index);
            this.Network.MessagePacker.SerializeToStream(message, stream);

            channel.Send(stream);
        }
예제 #4
0
파일: Session.cs 프로젝트: M599822330/ET
        private void SendMessage(byte flag, ushort opcode, uint rpcId, byte[] bytes)
        {
            this.flagBytes[0] = flag;

            List <byte[]> bb;

            if (rpcId == 0)
            {
                bb    = this.byteses;
                bb[0] = flagBytes;
                bb[1] = BitConverter.GetBytes(opcode);
                bb[2] = bytes;
            }
            else
            {
                bb    = this.rpcByteses;
                bb[0] = flagBytes;
                bb[1] = BitConverter.GetBytes(opcode);
                bb[2] = BitConverter.GetBytes(rpcId);
                bb[3] = bytes;
            }

#if SERVER
            // 如果是allserver,内部消息不走网络,直接转给session,方便调试时看到整体堆栈
            if (this.Network.AppType == AppType.AllServer)
            {
                Session session = this.Network.Entity.GetComponent <NetInnerComponent>().Get(this.RemoteAddress);
                this.pkt.Length = 0;
                ushort index = 0;
                foreach (var byts in bb)
                {
                    Array.Copy(byts, 0, this.pkt.Bytes, index, byts.Length);
                    index += (ushort)byts.Length;
                }

                this.pkt.Length = index;
                session.Run(this.pkt);
                return;
            }
#endif

            channel.Send(bb);
        }
예제 #5
0
파일: Session.cs 프로젝트: allexc123/ET
        public void Send(int opcode, long pid, object message)
        {
            if (this.IsDisposed)
            {
                throw new Exception("session已经被Dispose了");
            }

            //Log.Msg(message);

            MemoryStream stream = this.Stream;


            stream.Seek(0, SeekOrigin.Begin);
            stream.SetLength(0);

            this.Network.MessagePacker.SerializeTo(message, stream);



            channel.Send(opcode, pid, stream);
        }
예제 #6
0
 public void Send(MemoryStream stream)
 {
     channel.Send(stream);
 }
예제 #7
0
파일: Session.cs 프로젝트: Greatdust/ET4.0
 public void Send(MemoryStream stream)
 {
     channel.Send(stream);               //最终调用channel里面send
 }