Example #1
0
        public void MessageSolution(Message message, object sender)
        {
            switch (message.MessageType)
            {
                    case MessageType.ConnectionCheckFromClient:

                        var activity = ClientActivities.FirstOrDefault(t => t.ClientManager == (ClientManager) sender);
                        if (activity != null)
                            Application.Current.Dispatcher.BeginInvoke((Action)(() => { activity.Active = true; }));

                    break;
                case MessageType.FromClientWithResult:
                    var str = String.Concat("Сообщение от клиента #", message.ToClient, "\n", message.Data);
                    Application.Current.Dispatcher.BeginInvoke((Action)(() => { OutputString += str; }));
                    break;
            }
        }
Example #2
0
 public string FormMessage(MessageType type, string data, TaskType task, int num, int clnum)
 {
     var message = new Message(){MessageType = type,Data = data,NumberOfClients = clnum,Task = task,ToClient = num};
     if (type != MessageType.ConnectionCheckFromServer)
     {
         var brutalDictionaryLookAlikeIpList = new List<NumberIpPort>();
         for(int i =0;i<ClientManagers.Count;i++)
         {
             brutalDictionaryLookAlikeIpList.Add(new NumberIpPort(){Number = i, Ip = ClientManagers[i].ClientIp,Port = ClientManagers[i].ClientPort});
         }
         message.IpDictionary = brutalDictionaryLookAlikeIpList;
     }
     var builder = new StringBuilder();
     TextWriter writer = new StringWriter(builder);
     _serverXmlSerializer.Serialize(writer, message);
     return builder.ToString();
 }