예제 #1
0
 private void Instance_OnReceiveData(SocketManager.SocketClient sender, byte[] e)
 {
     if (e[0] == 1)
     {
         var data = FileCommunicationObject.ByteArrayToFile(e);
         if (data != null && data.ChatNum == this.ChatNum)
         {
             App.Current.Dispatcher.Invoke(new Action(() =>
             {
                 this.FileList.Add(data);
                 this.Messages.Add(data.Sender + " 님이 파일을 전송했습니다.");
             }));
         }
     }
     else
     {
         var data = CommunicationObject.Parse(Encoding.UTF8.GetString(e)) as ChatMessage;
         if (data != null && data.ChatNum == this.ChatNum)
         {
             Application.Current.Dispatcher.Invoke(new Action(() =>
             {
                 this.Messages.Add(data.Sender.UserID + " : " + data.Message);
             }));
         }
         var receiveData2 = FriendsCollection.Parse(Encoding.UTF8.GetString(e)) as FriendsCollection;
         if (receiveData2 != null)
         {
             this.Friends = receiveData2.Friends;
         }
     }
 }
예제 #2
0
 private void Instance_OnReceiveData(SocketManager.SocketClient sender, byte[] data)
 {
     if (data[0] != 1)
     {
         var receiveData = ChatInfo.Parse(Encoding.UTF8.GetString(data)) as ChatInfo;
         if (receiveData != null)
         {
             if (this.OnChatStart != null)
             {
                 this.OnChatStart(this, receiveData);
             }
             return;
         }
         var receiveData2 = FriendsCollection.Parse(Encoding.UTF8.GetString(data)) as FriendsCollection;
         if (receiveData2 != null)
         {
             this.Friends = receiveData2.Friends;
         }
     }
 }