public NetworkGeomagicTouchViewModel() { this.timer = new System.Timers.Timer(); this.talkerSocket = new TalkerSocket(); this.listenerSockets = new List<ListenerSocket>(); this.isStartConsoleButtonEnabled = true; this.connectedUsers = new MTObservableCollection<ConnectedUser>(); viewShouldUpdate = false; this.idOfUserWithControl = 0; }
public void SomeoneIsConnecting(string IPaddress, string Name) { ConnectedUser tmp = new ConnectedUser(); tmp.Ip = IPaddress; tmp.Name = Name; tmp.MyNumber = connectedUsers.Count + 1; tmp.HasControl = false; MTObservableCollection<ConnectedUser> newList = new MTObservableCollection<ConnectedUser>(); newList = connectedUsers; newList.Add(tmp); connectedUsers = new MTObservableCollection<ConnectedUser>(); connectedUsers = newList; this.RaisePropertyChanged("ConnectedUsers"); SocketMessage socketMessage = new SocketMessage(); socketMessage.Port = (listenerSockets.Count + 12001).ToString(); socketMessage.MessageType = "PortInformation"; talkerSocket = new TalkerSocket(IPaddress, ClientUnderlyingListenerPort); ListenerSocket newListenSocket = new ListenerSocket(Int32.Parse(socketMessage.Port), this); listenerSockets.Add(newListenSocket); listenerSockets.ElementAt(listenerSockets.Count - 1).StartListening(); talkerSocket.sendData(socketMessage); viewShouldUpdate = true; }