/** * Is invoked when application launches. Connects the Client to the Server */ public void OnUserConnect(string address, int port) { ChannelDispatcher dispatcher = new ChannelDispatcher(); this.transport = new TransportClient(dispatcher); sessionClient = new SessionClient(this.transport, this); dispatcher.RegisterChannel(sessionClient); surfaceClient = new SurfaceClient(this, this.transport); dispatcher.RegisterChannel(surfaceClient); inputClient = new InputClient(this.transport); dispatcher.RegisterChannel(inputClient); try { this.transport.Connect(address, port); DisplayStatusText("Welcome! You are connected to Screenary server at " + address + " : " + port); } catch (TransportException e) { ExceptionDialog exception = new ExceptionDialog("Operation Fail", "Could not connect to Screenary server at " + address + " : " + port + "\nVerify connections."); } }
/** * Class constructor */ public Client(TransportClient transport, IClientListener clientListener) { this.clientListener = clientListener; dispatcher = new ChannelDispatcher(); transport.SetChannelDispatcher(dispatcher); surfaceServer = new SurfaceServer(transport, this); dispatcher.RegisterChannel(surfaceServer); sessionServer = new SessionServer(transport, this); dispatcher.RegisterChannel(sessionServer); inputServer = new InputServer(transport, this); dispatcher.RegisterChannel(inputServer); transport.StartThread(); dispatcher.OnConnect(); }