コード例 #1
0
        public override void ExecuteCommand(string userId, string command)
        {
            ServerPresetsStatus vncData = deserialize.Deserialize <ServerPresetsStatus>(command);

            if (vncData == null)
            {
                return;
            }

            List <PresetModel> presetList = new List <PresetModel>();

            foreach (PresetsEntry entry in vncData.UserPresetList)
            {
                List <ApplicationModel> appList = new List <ApplicationModel>();
                foreach (ApplicationEntry appEntry in entry.ApplicationList)
                {
                    ApplicationModel appModel = new ApplicationModel()
                    {
                        AppliationId    = appEntry.Identifier,
                        ApplicationName = appEntry.Name,
                    };
                    appList.Add(appModel);
                }

                List <VncModel> vncList = new List <VncModel>();
                foreach (VncEntry vncEntry in entry.VncList)
                {
                    VncModel vncModel = new VncModel()
                    {
                        Identifier    = vncEntry.Identifier,
                        DisplayName   = vncEntry.DisplayName,
                        VncServerIp   = vncEntry.IpAddress,
                        VncServerPort = vncEntry.Port,
                    };

                    vncList.Add(vncModel);
                }

                PresetModel model = new PresetModel()
                {
                    PresetId        = entry.Identifier,
                    PresetName      = entry.Name,
                    ApplicationList = appList,
                    VncList         = vncList,
                    VisionInputList = entry.InputList,
                };

                presetList.Add(model);
            }

            ApplicationSettings.GetInstance().PresetList = vncData.UserPresetList;
            client.RefreshPresetList(presetList);
        }
コード例 #2
0
        public override void ExecuteCommand(string userId, string command)
        {
            ServerPresetsStatus vncData = deserialize.Deserialize <ServerPresetsStatus>(command);

            if (vncData == null)
            {
                return;
            }

            List <PresetModel> presetList = new List <PresetModel>();

            foreach (PresetsEntry entry in vncData.UserPresetList)
            {
                List <ApplicationModel> appList = new List <ApplicationModel>();
                foreach (ApplicationEntry appEntry in entry.ApplicationList)
                {
                    ApplicationModel appModel = new ApplicationModel()
                    {
                        AppliationId    = appEntry.Identifier,
                        ApplicationName = appEntry.Name,
                    };
                    appList.Add(appModel);
                }

                PresetModel model = new PresetModel()
                {
                    PresetId        = entry.Identifier,
                    PresetName      = entry.Name,
                    ApplicationList = appList,
                };

                presetList.Add(model);
            }

            client.RefreshPresetList(presetList);
        }
コード例 #3
0
        public override void ExecuteCommand(string userId, string command)
        {
            ClientPresetsCmd presetData = deserialize.Deserialize <ClientPresetsCmd>(command);

            if (presetData == null)
            {
                return;
            }

            bool broadcastChanges = false;

            switch (presetData.ControlType)
            {
            case ClientPresetsCmd.EControlType.Add:
                AddPreset(userId, clientId, presetData);
                broadcastChanges = true;
                break;

            case ClientPresetsCmd.EControlType.Delete:
                RemovePreset(presetData);
                broadcastChanges = true;
                break;

            case ClientPresetsCmd.EControlType.Launch:
                LaunchPreset(userId, clientId, presetData);
                break;

            case ClientPresetsCmd.EControlType.Modify:
                ModifyPreset(clientId, presetData);
                break;

            default:
                break;
            }

            if (broadcastChanges)
            {
                // TODO: broadcast changes to user who login using the owner's account
                // get user's preset list
                ServerPresetsStatus serverPresetStatus = new ServerPresetsStatus();
                serverPresetStatus.UserPresetList = new List <PresetsEntry>();
                foreach (PresetData data in Server.ServerDbHelper.GetInstance().GetPresetByUserId(clientId))
                {
                    List <ApplicationEntry> presetAppEntries = new List <ApplicationEntry>();
                    foreach (ApplicationData appData in data.AppDataList)
                    {
                        presetAppEntries.Add(new ApplicationEntry()
                        {
                            Identifier = appData.id,
                            Name       = appData.name
                        });
                    }

                    List <VncEntry> presetVncEntries = new List <VncEntry>();
                    foreach (RemoteVncData vncData in data.VncDataList)
                    {
                        presetVncEntries.Add(new VncEntry()
                        {
                            Identifier  = vncData.id,
                            DisplayName = vncData.name,
                            IpAddress   = vncData.remoteIp,
                            Port        = vncData.remotePort,
                        });
                    }

                    List <InputAttributes> presetInputEntries = new List <InputAttributes>();
                    foreach (VisionData inputData in data.InputDataList)
                    {
                        presetInputEntries.Add(
                            ServerVisionHelper.getInstance().GetAllVisionInputsAttributes().First(InputAttributes
                                                                                                  => InputAttributes.InputId == inputData.id));
                    }

                    serverPresetStatus.UserPresetList.Add(new PresetsEntry()
                    {
                        Identifier      = data.Id,
                        Name            = data.Name,
                        ApplicationList = presetAppEntries,
                        VncList         = presetVncEntries,
                        InputList       = presetInputEntries,
                    });
                }

                // should get all connected client with same login
                List <string> connectedClientSocketList;
                if (ConnectedClientHelper.GetInstance().GetConnectedUsersGroupByDB().TryGetValue(clientId, out connectedClientSocketList))
                {
                    server.GetConnectionMgr().SendData(
                        (int)CommandConst.MainCommandServer.UserPriviledge,
                        (int)CommandConst.SubCommandServer.PresetList,
                        serverPresetStatus,
                        connectedClientSocketList);
                }
                else
                {
                    // Should not happen, just in case
                    Trace.WriteLine("ERROR: cannot get connected user socket list by user db id: " + clientId);
                    server.GetConnectionMgr().SendData(
                        (int)CommandConst.MainCommandServer.UserPriviledge,
                        (int)CommandConst.SubCommandServer.PresetList,
                        serverPresetStatus,
                        new List <string>()
                    {
                        userId
                    });
                }
            }
        }
コード例 #4
0
        private void sendLoginReply(Server.Model.ClientInfoModel model, int dekstopRow, int desktopCol)
        {
            // get server's monitor info
            List <Session.Data.SubData.MonitorInfo> monitorList = new List <MonitorInfo>();
            int desktopLeft   = 0;
            int desktopTop    = 0;
            int desktopRight  = 0;
            int desktopBottom = 0;

            foreach (WindowsHelper.MonitorInfo monitor in Utils.Windows.WindowsHelper.GetMonitorList())
            {
                if (desktopLeft > monitor.WorkArea.Left)
                {
                    desktopLeft = monitor.MonitorArea.Left;
                }

                if (desktopTop > monitor.WorkArea.Top)
                {
                    desktopTop = monitor.MonitorArea.Top;
                }

                if (desktopRight < monitor.WorkArea.Right)
                {
                    desktopRight = monitor.MonitorArea.Right;
                }

                if (desktopBottom < monitor.WorkArea.Bottom)
                {
                    desktopBottom = monitor.MonitorArea.Bottom;
                }

                monitorList.Add(new Session.Data.SubData.MonitorInfo()
                {
                    LeftPos   = monitor.MonitorArea.Left,
                    TopPos    = monitor.MonitorArea.Top,
                    RightPos  = monitor.MonitorArea.Right,
                    BottomPos = monitor.MonitorArea.Bottom
                });
            }

            // send user data to client
            UserSettingData settingData = Server.ServerDbHelper.GetInstance().GetUserSetting(model.DbUserId);

            Session.Data.ServerUserSetting userSetting = new ServerUserSetting()
            {
                UserSetting = new UserSetting()
                {
                    gridX  = settingData.gridX,
                    gridY  = settingData.gridY,
                    isSnap = settingData.isSnap,
                }
            };

            // get user's application list
            ServerApplicationStatus serverAppStatus = new ServerApplicationStatus();

            serverAppStatus.UserApplicationList = new List <ApplicationEntry>();
            foreach (ApplicationData appData in Server.ServerDbHelper.GetInstance().GetAppsWithUserId(model.DbUserId))
            {
                serverAppStatus.UserApplicationList.Add(new ApplicationEntry()
                {
                    Identifier = appData.id,
                    Name       = appData.name
                });
            }

            // get user's preset list
            ServerPresetsStatus serverPresetStatus = new ServerPresetsStatus();

            serverPresetStatus.UserPresetList = new List <PresetsEntry>();
            foreach (PresetData presetData in Server.ServerDbHelper.GetInstance().GetPresetByUserId(model.DbUserId))
            {
                List <ApplicationEntry> presetAppEntries = new List <ApplicationEntry>();
                foreach (ApplicationData appData in presetData.AppDataList)
                {
                    presetAppEntries.Add(new ApplicationEntry()
                    {
                        Identifier = appData.id,
                        Name       = appData.name
                    });
                }

                List <VncEntry> presetVncEntries = new List <VncEntry>();
                foreach (RemoteVncData vncData in presetData.VncDataList)
                {
                    presetVncEntries.Add(new VncEntry()
                    {
                        Identifier  = vncData.id,
                        DisplayName = vncData.name,
                        IpAddress   = vncData.remoteIp,
                        Port        = vncData.remotePort,
                    });
                }

                // get all vision inputs
                List <InputAttributes> allInputList = Server.ServerVisionHelper.getInstance().GetAllVisionInputsAttributes();
                List <InputAttributes> inputEntries = new List <InputAttributes>();
                foreach (VisionData inputData in presetData.InputDataList)
                {
                    inputEntries.Add(new InputAttributes()
                    {
                        InputId     = inputData.id,
                        DisplayName = allInputList.First(inputAtt => inputAtt.InputId == inputData.id).DisplayName,
                    });
                }

                serverPresetStatus.UserPresetList.Add(new PresetsEntry()
                {
                    Identifier      = presetData.Id,
                    Name            = presetData.Name,
                    ApplicationList = presetAppEntries,
                    VncList         = presetVncEntries,
                    InputList       = inputEntries,
                });
            }

            // get user's priviledge
            ServerMaintenanceStatus maintenanceStatus = new ServerMaintenanceStatus();
            GroupData groupData = Server.ServerDbHelper.GetInstance().GetGroupByUserId(model.DbUserId);

            maintenanceStatus.AllowMaintenance   = groupData.allow_maintenance;
            maintenanceStatus.AllowRemoteControl = groupData.allow_remote;

            MonitorInfo allowViewingArea = new MonitorInfo();

            if (groupData.share_full_desktop)
            {
                // same as full desktop
                allowViewingArea.LeftPos   = desktopLeft;
                allowViewingArea.TopPos    = desktopTop;
                allowViewingArea.RightPos  = desktopRight;
                allowViewingArea.BottomPos = desktopBottom;
            }
            else
            {
                // get monitor info
                MonitorData monitorData = Server.ServerDbHelper.GetInstance().GetMonitorByGroupId(groupData.id);

                allowViewingArea.LeftPos   = monitorData.Left;
                allowViewingArea.TopPos    = monitorData.Top;
                allowViewingArea.RightPos  = monitorData.Right;
                allowViewingArea.BottomPos = monitorData.Bottom;
            }

            // prepare the VNC list
            ServerVncStatus vncStatus  = new ServerVncStatus();
            List <VncEntry> vncEntries = new List <VncEntry>();

            vncStatus.UserVncList = vncEntries;
            foreach (RemoteVncData vncData in ServerDbHelper.GetInstance().GetRemoteVncList())
            {
                vncEntries.Add(new VncEntry()
                {
                    Identifier  = vncData.id,
                    DisplayName = vncData.name,
                    IpAddress   = vncData.remoteIp,
                    Port        = vncData.remotePort,
                });
            }

            ServerLoginReply reply = new ServerLoginReply()
            {
                LoginName    = model.Name,
                UserId       = model.DbUserId,
                ServerLayout = new ServerScreenInfo()
                {
                    MatrixCol          = desktopCol,
                    MatrixRow          = dekstopRow,
                    ServerMonitorsList = monitorList
                },
                // UserApplications
                UserApplications = serverAppStatus,

                // UserPresets
                UserPresets = serverPresetStatus,

                // UserMaintenance
                UserMaintenance = maintenanceStatus,

                // allowed viewing area
                ViewingArea = allowViewingArea,

                // Current vnc list
                VncStatus = vncStatus,

                // user settings
                UserSetting = userSetting,
            };

            connectionMgr.SendData(
                (int)CommandConst.MainCommandServer.UserPriviledge,
                (int)CommandConst.SubCommandServer.DisplayInfo,
                reply,
                new List <string>()
            {
                model.SocketUserId
            });


            // send Input info to client
            Session.Data.ServerInputStatus inputStatus = new Session.Data.ServerInputStatus()
            {
                InputAttributesList = Server.ServerVisionHelper.getInstance().GetAllVisionInputsAttributes(),
            };

            connectionMgr.SendData(
                (int)CommandConst.MainCommandServer.Presents,
                (int)CommandConst.SubCommandServer.VisionInput,
                inputStatus,
                new List <string>()
            {
                model.SocketUserId
            });
        }