protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); this.serializer = new RMSerialization(); Button button = FindViewById<Button>(Resource.Id.MyButton); List<string> names = new List<string>(); names.Add("Aaa"); names.Add("Bbb"); clientsListUI = FindViewById<ListView>(Resource.Id.clientsList); listAdapter = new BasicListViewAdapter(this, names); clientsListUI.Adapter = listAdapter; AndroidServer = new Server(); AndroidServer.ReceivedBytes += ReceivedBytes; AndroidServer.StartTcp(); string myIp = AndroidNetworkData.GetLocalIp(); ClientInfo me = new ClientInfo("Android", myIp); AndroidClient = new Client(AndroidServer, me); byte[] msg = serializer.SerializeXmlToBytes(me); button.Click += delegate { button.Text = "Sending..."; //client.SendTcp("192.168.0.91", 11100, msg); AndroidServer.MultiUdp(msg); button.Text = "Sent"; }; }
public NetworkScanner(Server server, ClientInfo me) { this._server = server; this._me = me; this._serializer = new RMSerialization(); this._scanWaitInterval = (int)TimeSpan.FromMinutes(5).TotalMilliseconds; }
public void AddClientInfo(ClientInfo clientInfo) { if (!this.AvailableClientsInfo.Contains(clientInfo)) { this.AvailableClientsInfo.Add(clientInfo); } }
public bool TryAddTrustedClient(ClientInfo clientInfo) { if (!trustedClientInfos.Contains(clientInfo)) { trustedClientInfos.Add(clientInfo); return true; } return false; }
private async Task SendTcpAsync(ClientInfo clientInfo, byte[] message) { var client = new TcpSocketClient(); await client.ConnectAsync(clientInfo.IpAddress, SharedSettings.TcpPort); client.WriteStream.Write(message, 0, message.Length); await client.WriteStream.FlushAsync(); await client.DisconnectAsync(); }
public LocalSettings() { FirstRun = true; ClientName = "Windows"; Notes = new BindableCollection<NoteViewModel>(); TrustedClientsListItems = new BindableCollection<ClientInfoListItemViewModel>(); var myIp = WindowsNetworkData.GetLocalIpAddress(); var me = new ClientInfo(ClientName, myIp); this.Me = me; }
public Client(Server server, ClientInfo me) { if (server == null || me == null) { throw new ArgumentNullException(); } this.Me = me; this.AvailableClientsInfo = new ObservableCollection<IClientInfo>(); this.AvailableClientsInfo.CollectionChanged += AvailableClientsInfoChanged; this.TrusedClientsInfos = new TrustedClients(); var netScanner = new NetworkScanner(server, Me); netScanner.Run(); }
public void SendTcp(ClientInfo clientInfo, byte[] message) { Task.Run(() => SendTcpAsync(clientInfo, message)); }
public ClientInfoListItemViewModel(ClientInfo clientInfo) { this._clientInfo = clientInfo; }