Beispiel #1
0
 private void sendMsg(TcpMessage msg)
 {
     if (isServer)
     {
         socketServer.serverListener.sendAnotherUsersMessage(msg, null);
     }
     else
     {
         userChat.sendMessageObject(msg);
     }
 }
Beispiel #2
0
 public ChatForm(bool isServer = false, UserInfo userInfo = null)
 {
     InitializeComponent();
     this.isServer = isServer;
     if (isServer)
     {
         socketServer = new SocketServer(8080, this);
         socketServer.start();
         ChatRichTextForm.AppendText("Server start\n");
         userChat = new UserChat(new UserInfo("server"), this);
     }
     else
     {
         userChat = new UserChat(userInfo, this);
         userChat.sendMessageObject(new TcpMessage(TcpMessage.TypeMsg.Login, "", userInfo.getName()));
         //userChat.sendMessage(userInfo.getName());
         Thread backgroundThread = new Thread(new ThreadStart(userChat.listenNewMessage));
         backgroundThread.Start();
     }
 }