Beispiel #1
0
        public Server(ChatViewModelContainer chatViewModelContainer, ClientViewModelContainer clientViewModelContainer, LogViewModelContainer logViewModelContainer, Dispatcher dispatcher)
        {
            this.dispatcher = dispatcher;

            DatabaseManager dbManager = DatabaseManager.Instance;

            dbManager.CreatDatabase();
            dbManager.CreatTables();

            this.remoHttp = new RemoHttpServer();
            this.remoHttp.Start();

            this.ManagedServer            = new ManagedServer(IPAddress.IPv6Any, 2345);
            this.ManagedServer.BufferSize = 2 * 1024 * 1024;

            this.ManagedServer.ReceivedPacket     += ManagedServer_ReceivedPacket;
            this.ManagedServer.ClientConnected    += ManagedServer_ClientConnected;
            this.ManagedServer.ClientDisconnected += ManagedServer_ClientDisconnected;
            this.ManagedServer.Logger.LogWrite    += Logger_LogWrite;
            this.clientViewModelContainer          = clientViewModelContainer;
            this.chatViewModelContainer            = chatViewModelContainer;
            this.logViewModelContainer             = logViewModelContainer;

            this.handlePacket = new HandlePacket(this.chatViewModelContainer, this.clientViewModelContainer, this.dispatcher, this.ManagedServer.Logger, this);

            this.broadcast = new UDPSocket();
            this.broadcast.ReceivedPacket += Broadcast_ReceivedPacket;
        }
 private void InitializeFields()
 {
     this.logViewModelContainer    = new LogViewModelContainer(this.lvLogs);
     this.clientViewModelContainer = new ClientViewModelContainer(this.lvClients);
     this.chatViewModelContainer   = ChatViewModelContainer.Instance;
     this.server = new Server(this.chatViewModelContainer, this.clientViewModelContainer, this.logViewModelContainer, this.dispatcher);
     this.server.DisplayTrayBalloon += server_displayTrayBalloon;
     this.isListening = false;
 }
 public HandlePacket(ChatViewModelContainer chatViewModelContainer, ClientViewModelContainer clientViewModelContainer, Dispatcher dispatcher, Logger logger, Server server)
 {
     this.server = server;
     this.clientViewModelContainer = clientViewModelContainer;
     this.chatViewModelContainer   = chatViewModelContainer;
     this.dispatcher      = dispatcher;
     this.clientPacketIds = new Dictionary <int, IHandlePacket>();
     this.logger          = logger;
     this.InitPacketIds();
 }