示例#1
0
 public FileSender(ClientInfo client, string filePath, Dispatcher dispatcher)
 {
     targetIP = client.ClientIP;
     this.filePath = filePath;
     this.dispatcher = dispatcher;
 }
示例#2
0
        /// <summary>
        ///     处理收到的Info包
        /// </summary>
        /// <param name="info"></param>
        private void InfoProcessor(Info info)
        {
            switch (info.InfoType)
            {
                case Info.Types.InfoType.Login:
                    if (!ClientDictionary.ContainsKey(clientIP))
                    {
                        var clientInfo = new ClientInfo();
                        clientInfo.ClientIP = clientIP;
                        clientInfo.ClientName = ByteStringToString(info.DeviceName);
                        clientInfo.ClientStream = stream;

                        if (ClientDictionary.ContainsKey(clientIP))
                            ClientDictionary[clientIP] = clientInfo;
                        else
                            ClientDictionary.Add(clientIP, clientInfo);
                    }
                    break;
                case Info.Types.InfoType.Logout:

                    if (ClientDictionary.ContainsKey(clientIP))
                        ClientDictionary.Remove(clientIP);

                    break;
                case Info.Types.InfoType.NormalInfo:
                    if (info.Height == 0 && info.Width == 0 && info.PortListening == 0)
                    {
                        //deal as a request
                        InfoPacketSender();
                    }
                    else
                    {
                        if (info.HasDeviceName)
                        {
                            if (ClientDictionary.ContainsKey(clientIP))
                            {
                                var clientInfo = new ClientInfo();
                                clientInfo.ClientIP = clientIP;
                                clientInfo.ClientName = ByteStringToString(info.DeviceName);
                                clientInfo.ClientStream = stream;
                                ClientDictionary[clientIP] = clientInfo;
                            }
                        }

                        ClientScreenWidth = info.Width;
                        ClientScreenHeight = info.Height;

                        scaleRate = Math.Min(ClientScreenWidth / (float)Screen.PrimaryScreen.Bounds.Width,
                            ClientScreenHeight / (float)Screen.PrimaryScreen.Bounds.Height
                            );
                        if (scaleRate > 1)
                            scaleRate = 1;
                    }
                    break;
            }

            //notify UI
            dispatcher.BeginInvoke(MainWindow.RefreshDeviceList);
        }