当前位置: 首页>>代码示例>>C#>>正文


C# SocketServer.SendMessageToClient方法代码示例

本文整理汇总了C#中SocketServer.SendMessageToClient方法的典型用法代码示例。如果您正苦于以下问题:C# SocketServer.SendMessageToClient方法的具体用法?C# SocketServer.SendMessageToClient怎么用?C# SocketServer.SendMessageToClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketServer的用法示例。


在下文中一共展示了SocketServer.SendMessageToClient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowYesNoDialog

        /// <summary>
        /// Show a yes no dialog in MediaPortal and send the result to the sender
        /// </summary>
        /// <param name="dialogId">Id of dialog</param>
        /// <param name="title">Dialog title</param>
        /// <param name="text">Dialog text</param>
        /// <param name="socketServer">Server</param>
        /// <param name="sender">Sender of the request</param>
        internal static void ShowYesNoDialog(string dialogId, string title, string text, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
            if (dlg != null)
            {
                dlg.Reset();
                dlg.SetHeading(title);
                dlg.SetLine(1, text);
                dlg.DoModal(GUIWindowManager.ActiveWindow);

                MessageDialogResult result = new MessageDialogResult();
                result.YesNoResult = dlg.IsConfirmed;
                result.DialogId = dialogId;

                socketServer.SendMessageToClient(result, sender);
            }
        }
开发者ID:johanj,项目名称:WifiRemote,代码行数:25,代码来源:ShowDialogHelper.cs

示例2: ShowYesNoThenSelectDialog

        /// <summary>
        /// Show a yes/no dialog and if the user accepts, show a select dialog. After that, send the result to the sender.
        /// </summary>
        /// <param name="dialogId">Id of dialog</param>
        /// <param name="title">Dialog title</param>
        /// <param name="text">Dialog text</param>
        /// <param name="options">Options for the user to choose from</param>
        /// <param name="socketServer">Server</param>
        /// <param name="sender">Sender of the request</param>
        internal static void ShowYesNoThenSelectDialog(string dialogId, string title, string text, List<string> options, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            GUIDialogYesNo dlg = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
            MessageDialogResult result = new MessageDialogResult();
            result.DialogId = dialogId;
            result.YesNoResult = false;

            if (dlg != null)
            {
                dlg.Reset();
                dlg.SetHeading(title);
                dlg.SetLine(1, text);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }

            if (dlg.IsConfirmed && options != null && options.Count > 0)
            {
                if (options.Count == 1)
                {
                    //only one option, no need to show select dialog
                    result.SelectedOption = options[0];
                    result.YesNoResult = true;
                }
                else
                {
                    //multiple options available, show select menu to user
                    GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlgMenu != null)
                    {
                        dlgMenu.Reset();

                        dlgMenu.SetHeading(title);

                        if (options != null)
                        {
                            foreach (string o in options)
                            {
                                dlgMenu.Add(o);
                            }
                        }

                        //dlg.SetLine(1, text);
                        dlgMenu.DoModal(GUIWindowManager.ActiveWindow);

                        if (dlgMenu.SelectedId != -1)
                        {
                            result.YesNoResult = true;
                            result.SelectedOption = dlgMenu.SelectedLabelText;
                        }
                    }
                }
            }

            socketServer.SendMessageToClient(result, sender);
        }
开发者ID:johanj,项目名称:WifiRemote,代码行数:64,代码来源:ShowDialogHelper.cs

示例3: HandlePlaylistMessage

        /// <summary>
        /// Handle an Playlist message received from a client
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="socketServer">Socket server</param>
        /// <param name="sender">Sender</param>
        internal static void HandlePlaylistMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            String action = (string)message["PlaylistAction"];
            String playlistType = (message["PlaylistType"] != null) ? (string)message["PlaylistType"] : "music";
            bool shuffle = (message["Shuffle"] != null) ? (bool)message["Shuffle"] : false;
            bool autoPlay = (message["AutoPlay"] != null) ? (bool)message["AutoPlay"] : false;
            bool showPlaylist = (message["ShowPlaylist"] != null) ? (bool)message["ShowPlaylist"] : true;

            if (action.Equals("new") || action.Equals("append"))
            {
                //new playlist or append to playlist
                int insertIndex = 0;
                if (message["InsertIndex"] != null)
                {
                    insertIndex = (int)message["InsertIndex"];
                }

                // Add items from JSON or SQL
                JArray array = (message["PlaylistItems"] != null) ? (JArray)message["PlaylistItems"] : null;
                JObject sql = (message["PlayListSQL"] != null) ? (JObject)message["PlayListSQL"] : null;
                if (array != null || sql != null)
                {
                    if (action.Equals("new"))
                    {
                        PlaylistHelper.ClearPlaylist(playlistType, false);
                    }

                    int index = insertIndex;

                    if (array != null)
                    {
                        // Add items from JSON
                        foreach (JObject o in array)
                        {
                            PlaylistEntry entry = new PlaylistEntry();
                            entry.FileName = (o["FileName"] != null) ? (string)o["FileName"] : null;
                            entry.Name = (o["Name"] != null) ? (string)o["Name"] : null;
                            entry.Duration = (o["Duration"] != null) ? (int)o["Duration"] : 0;
                            PlaylistHelper.AddItemToPlaylist(playlistType, entry, index, false);
                            index++;
                        }
                        PlaylistHelper.RefreshPlaylistIfVisible();

                        if (shuffle)
                        {
                            PlaylistHelper.Shuffle(playlistType);
                        }
                    }
                    else
                    {
                        // Add items with SQL
                        string where = (sql["Where"] != null) ? (string)sql["Where"] : String.Empty;
                        int limit = (sql["Limit"] != null) ? (int)sql["Limit"] : 0;

                        PlaylistHelper.AddSongsToPlaylistWithSQL(playlistType, where, limit, shuffle, insertIndex);
                    }

                    if (autoPlay)
                    {
                        if (message["StartPosition"] != null)
                        {
                            int startPos = (int)message["StartPosition"];
                            insertIndex += startPos;
                        }
                        PlaylistHelper.StartPlayingPlaylist(playlistType, insertIndex, showPlaylist);
                    }
                }
            }
            else if (action.Equals("load"))
            {
                //load a playlist
                string playlistName = (string)message["PlayListName"];
                string playlistPath = (string)message["PlaylistPath"];

                if (!string.IsNullOrEmpty(playlistName) || !string.IsNullOrEmpty(playlistPath))
                {
                    PlaylistHelper.LoadPlaylist(playlistType, (!string.IsNullOrEmpty(playlistName)) ? playlistName : playlistPath, shuffle);
                    if (autoPlay)
                    {
                        PlaylistHelper.StartPlayingPlaylist(playlistType, 0, showPlaylist);
                    }
                }
            }
            else if (action.Equals("get"))
            {
                //get all playlist items of the currently active playlist
                List<PlaylistEntry> items = PlaylistHelper.GetPlaylistItems(playlistType);

                MessagePlaylistDetails returnPlaylist = new MessagePlaylistDetails();
                returnPlaylist.PlaylistType = playlistType;
                returnPlaylist.PlaylistItems = items;

                socketServer.SendMessageToClient(returnPlaylist, sender);
            }
//.........这里部分代码省略.........
开发者ID:johanj,项目名称:WifiRemote,代码行数:101,代码来源:PlaylistMessageHandler.cs

示例4: HandleFacadeMessage

        /// <summary>
        /// Handle the facade message
        /// </summary>
        /// <param name="message">Message sent from client</param>
        /// <param name="server">Instance of the socket server</param>
        /// <param name="client">Socket that sent the message (for return messages)</param>
        internal static void HandleFacadeMessage(Newtonsoft.Json.Linq.JObject message, SocketServer server, AsyncSocket client)
        {
            String action = (string)message["FacadeAction"];
            GUIWindow currentPlugin = GUIWindowManager.GetWindow(GUIWindowManager.ActiveWindow);

            if (action.Equals("get"))
            {
                MessageFacade returnMessage = new MessageFacade();
                if (currentPlugin.GetType() == typeof(GUIHome))
                {
                    GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50);
                    List<FacadeItem> items = MpFacadeHelper.GetHomeItems(menu);
                    returnMessage.FacadeItems = items;
                    returnMessage.ViewType = "Home";
                }
                else
                {
                    GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50);
                    if (facade != null)
                    {
                        List<FacadeItem> items = MpFacadeHelper.GetFacadeItems(currentPlugin.GetID, 50);
                        returnMessage.ViewType = facade.CurrentLayout.ToString();
                        returnMessage.FacadeItems = items;
                    }
                }

                returnMessage.WindowId = currentPlugin.GetID;
                server.SendMessageToClient(returnMessage, client);
            }
            else if (action.Equals("setselected"))
            {
                if (currentPlugin.GetType() == typeof(GUIHome))
                {

                }
                else
                {
                    GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50);
                    int selected = (int)message["SelectedIndex"];
                    facade.SelectedListItemIndex = selected;
                }
            }
            else if (action.Equals("getselected"))
            {
                if (currentPlugin.GetType() == typeof(GUIHome))
                {
                    //TODO: find a way to retrieve the currently selected home button
                }
                else
                {
                    GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50);
                    int selected = facade.SelectedListItemIndex;
                }
            }
            else if (action.Equals("getcount"))
            {
                if (currentPlugin.GetType() == typeof(GUIHome))
                {
                    GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50);
                    int count = menu.ButtonInfos.Count;
                }
                else
                {
                    GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50);
                    int count = facade.Count;
                }
            }
            else if (action.Equals("select"))
            {
                int selected = (int)message["SelectedIndex"];
                if (currentPlugin.GetType() == typeof(GUIHome))
                {
                    GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50);
                    MenuButtonInfo info = menu.ButtonInfos[selected];
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, info.PluginID, 0, null);
                    GUIWindowManager.SendThreadMessage(msg);
                }
                else
                {
                    GUIFacadeControl facade = (GUIFacadeControl)currentPlugin.GetControl(50);
                    //TODO: is there a better way to select a list item

                    facade.SelectedListItemIndex = selected;
                    new Communication().SendCommand("ok");
                }
            }
            else if (action.Equals("context"))
            {
                int selected = (int)message["SelectedIndex"];
                if (currentPlugin.GetType() == typeof(GUIHome))
                {
                    GUIMenuControl menu = (GUIMenuControl)currentPlugin.GetControl(50);
                    MenuButtonInfo info = menu.ButtonInfos[selected];
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, info.PluginID, 0, null);
//.........这里部分代码省略.........
开发者ID:johanj,项目名称:WifiRemote,代码行数:101,代码来源:MpFacadeMessageHandler.cs

示例5: HandleDialogAction

        /// <summary>
        /// Handle the dialog action
        /// </summary>
        /// <param name="message">Message from Client</param>
        internal static void HandleDialogAction(Newtonsoft.Json.Linq.JObject message, SocketServer server, AsyncSocket client)
        {
            String action = (string)message["ActionType"];
            int dialogId = (int)message["DialogId"];
            int index = (int)message["Index"];

            if (action.Equals("get"))
            {
                if (MpDialogsHelper.IsDialogShown)
                {
                    MessageDialog msg = MpDialogsHelper.GetDialogMessage(MpDialogsHelper.CurrentDialog);
                    server.SendMessageToClient(msg, client);
                }
                else
                {
                    MessageDialog msg = new MessageDialog();
                    msg.DialogShown = false;
                    server.SendMessageToClient(msg, client);
                }
            }
            else
            {
                if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_MENU)
                {
                    MpDialogMenu diag = MpDialogsHelper.GetDialogMenu();
                    diag.HandleAction(action, index);
                }
                else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_OK)
                {
                    MpDialogOk diag = MpDialogsHelper.GetDialogOk();
                    diag.HandleAction(action, index);
                }
                else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_YES_NO)
                {
                    MpDialogYesNo diag = MpDialogsHelper.GetDialogYesNo();
                    diag.HandleAction(action, index);
                }
                else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY)
                {
                    MpDialogNotify diag = MpDialogsHelper.GetDialogNotify();
                    diag.HandleAction(action, index);
                }
                else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS)
                {
                    MpDialogProgress diag = MpDialogsHelper.GetDialogProgress();
                    diag.HandleAction(action, index);
                }
                else if (dialogId == (int)GUIWindow.Window.WINDOW_DIALOG_RATING)
                {
                    MpDialogRating diag = MpDialogsHelper.GetDialogRating();
                    diag.HandleAction(action, index);
                }
                else if (dialogId == MpDialogsHelper.TVSERIES_RATING_ID)
                {
                    if (WifiRemote.IsAvailableTVSeries)
                    {
                        MpDialogTvSeriesRating diag = MpDialogsHelper.GetDialogMpTvSeriesRating();
                        diag.HandleAction(action, index);
                    }
                }
                else if (dialogId == MpDialogsHelper.TVSERIES_PIN_ID)
                {
                    if (WifiRemote.IsAvailableTVSeries)
                    {
                        MpDialogTvSeriesPin diag = MpDialogsHelper.GetDialogMpTvSeriesPin();
                        diag.HandleAction(action, index);
                    }
                }
                else if (dialogId == MpDialogsHelper.MOPI_RATING_ID)
                {
                    if (WifiRemote.IsAvailableMovingPictures)
                    {
                        MpDialogMovingPicturesRating diag = MpDialogsHelper.GetDialogMovingPicturesRating();
                        diag.HandleAction(action, index);
                    }
                }
                else if (dialogId == MpDialogsHelper.MOPI_PIN_ID)
                {
                    if (WifiRemote.IsAvailableMovingPictures)
                    {
                        MpDialogMovingPicturesPin diag = MpDialogsHelper.GetDialogMovingPicturesPin();
                        diag.HandleAction(action, index);
                    }
                }
            }
        }
开发者ID:johanj,项目名称:WifiRemote,代码行数:90,代码来源:MpDialogsMessageHandler.cs


注:本文中的SocketServer.SendMessageToClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。