Esempio n. 1
0
        public void Disconnect()
        {
            Packet packet = new Packet(0);

            packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.DisconnectClient, this.id);
            this.virtualServer.Transmit(packet);
        }
Esempio n. 2
0
        public VirtualClient LinkVirtualClient(int id, int ip, int port)
        {
            Packet packet = new Packet(0);

            packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.ConnectClient, id);
            this.tcpClient.Transmit(packet);
            return(this.AddVirtualClient(id, ip, port));
        }
Esempio n. 3
0
        internal void DestroyVirtualClientGroup(VirtualClientGroup vcGroup)
        {
            Packet packet = new Packet(0)
            {
                InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.DestroyClientGroup, 0)
            };

            VirtualPacketFlag.SetSecondaryTargetID(packet, vcGroup.ID);
            this.tcpClient.Transmit(packet);
        }
Esempio n. 4
0
        private void Disable()
        {
            this.connectedServer = null;
            Packet packet = new Packet(0);

            packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.ClientDisconnect, this.id);
            for (int i = 0; i < this.connectedServerIndexList.Count; i++)
            {
                this.bridge.SendToServer(this.connectedServerIndexList[i], packet);
            }
            this.connectedServerIndexList.Clear();
        }
Esempio n. 5
0
        public VirtualClientGroup CreateVirtualClientGroup()
        {
            int    num    = Interlocked.Increment(ref this.nextGroupID);
            Packet packet = new Packet(0)
            {
                InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.CreateClientGroup, 0)
            };

            VirtualPacketFlag.SetSecondaryTargetID(packet, num);
            this.tcpClient.Transmit(packet);
            return(new VirtualClientGroup(this, num));
        }
        public void Remove(VirtualClient virtualClient)
        {
            if (virtualClient.Server != this.server)
            {
                throw new ArgumentException("Different virtual server.");
            }
            Packet packet = new Packet(0)
            {
                InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.RemoveClientGroupMember, virtualClient.ID)
            };

            VirtualPacketFlag.SetSecondaryTargetID(packet, this.id);
            this.server.Transmit(packet);
        }
Esempio n. 7
0
        public void OpenServer(int serverID)
        {
            this.connectedServer[serverID] = true;
            this.connectedServerIndexList.Add(serverID);
            Packet packet = new Packet(8);

            packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.ClientConnect, this.id);
            Buffer.BlockCopy(this.client.RemoteEndPoint.Address.GetAddressBytes(), 0, packet.Array, packet.Offset + packet.BodyOffset, 4);
            Buffer.BlockCopy(BitConverter.GetBytes(this.client.RemoteEndPoint.Port), 0, packet.Array, packet.Offset + packet.BodyOffset + 4, 4);
            this.bridge.SendToServer(serverID, packet);
            this.Transmit(new Packet
            {
                InstanceId = (long)(256 | VirtualPacketFlag.GenerateClientFlag(serverID))
            });
        }
Esempio n. 8
0
        private void Client_PacketReceive(object sender, EventArgs <ArraySegment <byte> > e)
        {
            Packet packet = new Packet(e.Value);

            if ((packet.InstanceId & -65536L) != -1068630016L)
            {
                throw new ArgumentException("Invalid client packet header.");
            }
            int  num        = (int)((byte)packet.InstanceId);
            long instanceId = packet.InstanceId;

            if (this.connectedServer[num])
            {
                packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.SingleTransferMessage, this.id);
                this.bridge.SendToServer(num, packet);
            }
        }
Esempio n. 9
0
        public void CloseServer(int serverID)
        {
            if (this.connectedServer == null)
            {
                return;
            }
            this.connectedServer[serverID] = false;
            int index  = this.connectedServerIndexList.IndexOf(serverID);
            int index2 = this.connectedServerIndexList.Count - 1;

            this.connectedServerIndexList[index] = this.connectedServerIndexList[index2];
            this.connectedServerIndexList.RemoveAt(index2);
            Packet packet = new Packet(0);

            packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.ClientDisconnect, this.id);
            this.bridge.SendToServer(serverID, packet);
            this.Transmit(new Packet(0)
            {
                InstanceId = (long)(512 | VirtualPacketFlag.GenerateClientFlag(serverID))
            });
        }
Esempio n. 10
0
 public void Transmit(IEnumerable <Packet> packets)
 {
     this.virtualServer.Transmit(EnumerablePacketFlagModifier.Convert(packets, VirtualPacketFlag.GenerateFlag(TransrouterMessage.SingleTransferMessage, this.id)));
 }
Esempio n. 11
0
 public void Transmit(Packet packet)
 {
     packet.InstanceId = (long)VirtualPacketFlag.GenerateFlag(TransrouterMessage.SingleTransferMessage, this.id);
     this.virtualServer.Transmit(packet);
 }