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; }
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; }
internal void SomeoneIsConnecting(string IPaddress, string Name) { User1Label.Text = "User1 : " + Name + " has connected with an IP address of " + IPaddress; 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); }
private void InitializeOmnis_Click(object sender, EventArgs e) { if (spRightOmni.SelectedIndex == -1 && spLeftOmni.SelectedIndex == -1) { MessageBox.Show("Both the Left and Right Omni's need to be selected"); } else if (spRightOmni.SelectedIndex == -1) { MessageBox.Show("Select a valid Right Omni"); } else if (spLeftOmni.SelectedIndex == -1) { MessageBox.Show("Select a valid Left Omni"); } else if (spLeftOmni.SelectedIndex == spRightOmni.SelectedIndex) { MessageBox.Show("Please select two different Omni Devices"); } else { string Left = spLeftOmni.SelectedItem.ToString(); string Right = spRightOmni.SelectedItem.ToString(); int error = initAndSchedule(Left, Right); if (error == 1) { lock1(); lock2(); btStop.Enabled = false; UnderlyingTimer.Enabled = true; } else { MessageBox.Show("Omni initialization error. Please check connections and try again."); } if (cb_isMaster.Checked && !tb_ipAddress.Text.Equals("")) { //start sending omni info talkerSocket = new TalkerSocket(tb_ipAddress.Text, port); canSend = true; } else if (cb_isMaster.Checked && tb_ipAddress.Text.Equals("")) { MessageBox.Show("Please enter an IP address to send to."); } } }