Exemplo n.º 1
0
        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";
            };
        }
Exemplo n.º 2
0
 public NetworkScanner(Server server, ClientInfo me)
 {
     this._server = server;
     this._me = me;
     this._serializer = new RMSerialization();
     this._scanWaitInterval = (int)TimeSpan.FromMinutes(5).TotalMilliseconds;
 }
Exemplo n.º 3
0
 public void AddClientInfo(ClientInfo clientInfo)
 {
     if (!this.AvailableClientsInfo.Contains(clientInfo))
     {
         this.AvailableClientsInfo.Add(clientInfo);
     }
 }
Exemplo n.º 4
0
        public bool TryAddTrustedClient(ClientInfo clientInfo)
        {
            if (!trustedClientInfos.Contains(clientInfo))
            {
                trustedClientInfos.Add(clientInfo);
                return true;
            }

            return false;
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        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();
        }
Exemplo n.º 8
0
 public void SendTcp(ClientInfo clientInfo, byte[] message)
 {
     Task.Run(() => SendTcpAsync(clientInfo, message));
 }
Exemplo n.º 9
0
 public ClientInfoListItemViewModel(ClientInfo clientInfo)
 {
     this._clientInfo = clientInfo;
 }