public void TestSetup()
        {
            SocketServer = new ServerInstance(11000, 1);
            var protocol = new Battlefield3Protocol() {Bf3Server = {Password = "******"}};
            SocketServer.SetProtocol(protocol);

            Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            ServerInstance = protocol.Bf3Server;
            Session = Connect();
            Session.StartReceiving();
        }
 public void TestCleanUp()
 {
     if (Socket != null)
     {
         Socket.Close();
         Socket = null;
     }
     if (Session != null)
     {
         Session = null;
     }
     if (ServerInstance != null)
     {
         SocketServer.Stop();
         SocketServer = null;
     }
 }
예제 #3
0
 private void InvokeClientConnected(PacketSession packetSession)
 {
     if (ClientConnected != null)
     {
         var invList = ClientConnected.GetInvocationList();
         foreach (var invDelegate in invList)
         {
             invDelegate.DynamicInvoke(this, new PacketSessionEventArgs(packetSession));
         }
     }
 }
예제 #4
0
 public void OnClientConnected(object sender, ClientEventArgs e)
 {
     var packetSession = new PacketSession(e.Session, this);
     lock (syncRoot)
     {
         PacketSessions.Add(packetSession);
     }
     InvokeClientConnected(packetSession);
 }
 public PacketSessionEventArgs(PacketSession session)
 {
     this.PacketSession = session;
 }
예제 #6
0
        private void InvokeSessionClosed(PacketSession packetSession)
        {
            if (SessionClosed == null) return;

            SessionClosed.InvokeAll(this, new PacketSessionEventArgs(this));
        }