public static bool Test_ClientMessageHandler() { bool result = false; LPConnector connector = null; ClientMessageHandler clientMessageHandler = null; clientMessageHandler = new ClientMessageHandler(); if (LOG_ERROR(clientMessageHandler != null)) { goto Exit0; } result = LP.Init(EPlatform.Pc, true, clientMessageHandler); if (ERROR(result)) { goto Exit0; } connector = LP.NetModule.CreateConnector(clientMessageHandler); if (LOG_ERROR(connector != null)) { goto Exit0; } result = connector.Start("127.0.0.1", 7777); if (LOG_ERROR(result)) { goto Exit0; } Exit0: return(true); }
private void btnConnect_Click(object sender, RoutedEventArgs e) { if (_client != null) { btnDisconnect_Click(this, e); } _client = new TcpClient(); _client.Connect("127.0.0.1", 8888); ClientMessageHandler .FromClient(_client) .ObserveOnDispatcher() .Subscribe(msg => { var clMessage = msg as ClientMessages.ClientMessage; if (clMessage != null) { _messages.Add(clMessage.Message); } }, err => { _messages.Add("Disconnected"); DisposeClient(); }, () => { _messages.Add("RX Stream Terminated"); DisposeClient(); }); }