protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.client_layout); lblConnectStatus = FindViewById<TextView>(Resource.Id.lblConnectStatus); txtIPAddress = FindViewById<EditText>(Resource.Id.txtIPAddress); txtPort = FindViewById<EditText>(Resource.Id.txtPort); txtMessage = FindViewById<EditText>(Resource.Id.txtMessage); btnConnect = FindViewById<Button>(Resource.Id.btnConnect); txtIPAddress.SetOnEditorActionListener(this); txtPort.SetOnEditorActionListener(this); txtMessage.SetOnEditorActionListener(this); btnConnect.Click += BtnConnect_Click; socketClient = new SocketClient(); socketClient.StateChanged += SocketClient_StateChanged; }
public override void ViewDidLoad () { base.ViewDidLoad (); btnConnect.TouchUpInside += BtnConnect_TouchUpInside; txtIPAddress.ShouldReturn = SearchShouldReturn; txtPort.ShouldReturn = SearchShouldReturn; txtMessage.ShouldReturn = SearchShouldReturn; socketClient = new SocketClient(); socketClient.StateChanged += SocketClient_StateChanged; }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); if (socketClient != null) { if (socketClient.State != SocketClientState.Disconnected) { socketClient.Disconnect(); } socketClient.StateChanged -= SocketClient_StateChanged; socketClient = null; } if (socketBroadcastServer != null) { if (socketBroadcastServer.State != SocketServerState.Stopped) { socketBroadcastServer.Stop(); } socketBroadcastServer.ReceivedMessage -= SocketBroadcastServer_ReceivedMessage; socketBroadcastServer = null; } if (socketBroadcastClient != null) { socketBroadcastClient.Dispose(); socketBroadcastClient = null; } serverList.Clear(); serverList = null; }
public override void ViewDidLoad() { base.ViewDidLoad (); tblServerList.RegisterNibForCellReuse (ServerTableViewCell.Nib, ServerTableViewCell.Key); serverList = new List<ServerInfo>(); var serverListSource = new ServerListTableViewSource (serverList); serverListSource.SelectedItem += ServerListSource_SelectedItem; tblServerList.Source = serverListSource; tblServerList.ReloadData (); btnConnect.TouchUpInside += BtnConnect_TouchUpInside; txtIPAddress.ShouldReturn = SearchShouldReturn; txtPort.ShouldReturn = SearchShouldReturn; txtMessage.ShouldReturn = SearchShouldReturn; socketClient = new SocketClient(); socketClient.StateChanged += SocketClient_StateChanged; socketBroadcastServer = new SocketBroadcastServer(); socketBroadcastServer.ReceivedMessage += SocketBroadcastServer_ReceivedMessage; socketBroadcastServer.Run(BROADCAST_PORT); socketBroadcastClient = new SocketBroadcastClient(BROADCAST_PORT); }