コード例 #1
0
        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();
        }
コード例 #2
0
 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);
 }
コード例 #5
0
 public PacketSessionEventArgs(PacketSession session)
 {
     this.PacketSession = session;
 }
コード例 #6
0
        private void InvokeSessionClosed(PacketSession packetSession)
        {
            if (SessionClosed == null) return;

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