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


C# SocketServer类代码示例

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


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

示例1: ShowSelectDialog

        /// <summary>
        /// Show a select dialog in MediaPortal. 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 ShowSelectDialog(string dialogId, string title,  List<string> options, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            GUIDialogMenu dlgMenu = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                       MessageDialogResult result = new MessageDialogResult();
            result.DialogId = dialogId;
            result.YesNoResult = false;

            if (dlgMenu != null)
            {
                dlgMenu.Reset();
                dlgMenu.SetHeading(title);

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

                dlgMenu.DoModal(GUIWindowManager.ActiveWindow);

                if (dlgMenu.SelectedId != -1)
                {
                    result.YesNoResult = true;
                    result.SelectedOption = dlgMenu.SelectedLabelText;
                }
            }
        }
开发者ID:johanj,项目名称:WifiRemote,代码行数:38,代码来源:ShowDialogHelper.cs

示例2: ServiceHandleManagerTest

 public void ServiceHandleManagerTest()
 {
     SocketServer target = new SocketServer(); // TODO: 初始化为适当的值
     ServiceHandleManager actual;
     actual = target.ServiceHandleManager;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:7,代码来源:SocketServerTest.cs

示例3: IsConnectedTest

 public void IsConnectedTest()
 {
     SocketServer target = new SocketServer(); // TODO: 初始化为适当的值
     bool actual;
     actual = target.IsConnected;
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }
开发者ID:andyhebear,项目名称:HappyQ-WowServer,代码行数:7,代码来源:SocketServerTest.cs

示例4: MainWindow

 public MainWindow()
 {
     InitializeComponent();
     // 시작 시, 연결을 위한 소켓을 비어있는 상태로 생성한다.
     // 방향키 트리거에 의한 오류방지를 위한 것.
     server = new SocketServer();
 }
开发者ID:Ohmry,项目名称:Univ-Projects,代码行数:7,代码来源:MainWindow.xaml.cs

示例5: HandleShowDialogMessage

        /// <summary>
        /// Handle a "showdialog" 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 HandleShowDialogMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            String dialogType = (String)message["DialogType"];
            String dialogId = (String)message["DialogId"];

            if (dialogType != null)
            {
                String title = (String)message["Title"];
                String text = (String)message["Text"];

                if (dialogType.Equals("yesno"))
                {
                    //show dialog in new thread so we don't block the tcp thread
                    new Thread(new ParameterizedThreadStart(ShowYesNoThreaded)).Start(new object[] { dialogId, title, text, socketServer, sender });
                }
                else if (dialogType.Equals("ok"))
                {
                    new Thread(new ParameterizedThreadStart(ShowOkDialogThreaded)).Start(new object[] { title, text });
                }
                else if (dialogType.Equals("yesnoselect"))
                {
                    List<String> options = new List<String>();
                    JArray array = (JArray)message["Options"];
                    if (array != null)
                    {
                        foreach (JValue v in array)
                        {
                            options.Add((string)v.Value);
                        }
                    }

                    //show dialog in new thread so we don't block the tcp thread
                    new Thread(new ParameterizedThreadStart(ShowYesNoThenSelectThreaded)).Start(new object[] { dialogId, title, text, options, socketServer, sender });
                }
                else if (dialogType.Equals("select"))
                {
                    List<String> options = new List<String>();
                    JArray array = (JArray)message["Options"];
                    if (array != null)
                    {
                        foreach (JValue v in array)
                        {
                            options.Add((string)v.Value);
                        }
                    }

                    //show dialog in new thread so we don't block the tcp thread
                    new Thread(new ParameterizedThreadStart(ShowSelectThreaded)).Start(new object[] { dialogId, title, options, socketServer, sender });
                }
                else
                {
                    WifiRemote.LogMessage("Dialog type " + dialogType + " not supported yet", WifiRemote.LogType.Warn);
                }
            }
            else
            {
                WifiRemote.LogMessage("No dialog type specified", WifiRemote.LogType.Warn);
            }
        }
开发者ID:Kucheek,项目名称:WifiRemote,代码行数:65,代码来源:ShowDialogMessageHandler.cs

示例6: SocketServerWorker

    public SocketServerWorker(SocketServer _server, TcpClient _client, int _id)
    {
        server = _server;
        id = _id;
        client = _client;

        socket = client.Client;

        Log.AddToDebug(id + "|SocketServerWorker Created");
    }
开发者ID:mariojgpinto,项目名称:PCMobileCOM,代码行数:10,代码来源:SocketServerWorker.cs

示例7: btn_Start_Click

        private void btn_Start_Click(object sender, EventArgs e)
        {
            try
            {
                SocketServer s = new SocketServer();
                s.Start();
                this.btn_Start.Enabled = false;
            }
            catch (Exception ex)
            {
                throw;
            }

        }
开发者ID:threelamb,项目名称:Test.WinformCS,代码行数:14,代码来源:Main.cs

示例8: 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

示例9: Login

    protected override void Login(string facebookAppID)
    {
        JavaVM.AttachCurrentThread ();
        //Find current Activity
        IntPtr clsActivity = JNI.FindClass ("com/unity3d/player/UnityPlayer");
        IntPtr objActivity = JNI.GetStaticObjectField (clsActivity, JNI.GetStaticFieldID (clsActivity, "currentActivity", "Landroid/app/Activity;"));
        //Create LoginAdapter obj
        IntPtr clsLAdapter = JNI.FindClass ("com/socialnetwork/LoginAdapter");
        IntPtr objlAdapter = JNI.NewObject (clsLAdapter, JNI.GetMethodID (clsLAdapter, "<init>", "(Landroid/app/Activity;)V"), objActivity);
        IntPtr lAdapter = JNI.NewGlobalRef (objlAdapter);

        if (JNI.CallBooleanMethod (lAdapter, JNI.GetMethodID (clsLAdapter, "Login", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z"), JNI.NewStringUTF (facebookAppID), JNI.NewStringUTF (host), JNI.NewStringUTF (port.ToString ()), JNI.NewStringUTF ("fb")) == 0) {
            return;
        }
        socketServer = new SocketServer (port);
        socketServer.ReadString += OnLoginEnded;
    }
开发者ID:rganeyev,项目名称:unity-facebook,代码行数:17,代码来源:AndroidLogin.cs

示例10: HandleMpExtendedMessage

        /// <summary>
        /// Handle an MpExtended 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 HandleMpExtendedMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            string itemId = (string)message["ItemId"];
            int itemType = (int)message["MediaType"];
            int providerId = (int)message["ProviderId"];
            String action = (String)message["Action"];
            Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(message["PlayInfo"].ToString());
            int startPos = (message["StartPosition"] != null) ? (int)message["StartPosition"] : 0;

            if (action != null)
            {
                if (action.Equals("play"))
                {
                    //play the item in MediaPortal
                    WifiRemote.LogMessage("play mediaitem: ItemId: " + itemId + ", itemType: " + itemType + ", providerId: " + providerId, WifiRemote.LogType.Debug);
                    MpExtendedHelper.PlayMediaItem(itemId, itemType, providerId, values, startPos);
                }
                else if (action.Equals("show"))
                {
                    //show the item details in mediaportal (without starting playback)
                    WifiRemote.LogMessage("play mediaitem: ItemId: " + itemId + ", itemType: " + itemType + ", providerId: " + providerId, WifiRemote.LogType.Debug);

                    MpExtendedHelper.ShowMediaItem(itemId, itemType, providerId, values);
                }
                else if (action.Equals("enqueue"))
                {
                    //enqueue the mpextended item to the currently active playlist
                    WifiRemote.LogMessage("enqueue mediaitem: ItemId: " + itemId + ", itemType: " + itemType + ", providerId: " + providerId, WifiRemote.LogType.Debug);

                    int startIndex = (message["StartIndex"] != null) ? (int)message["StartIndex"] : -1;

                    PlayListType playlistType = PlayListType.PLAYLIST_VIDEO;
                    List<PlayListItem> items = MpExtendedHelper.CreatePlayListItemItem(itemId, itemType, providerId, values, out playlistType);

                    PlaylistHelper.AddPlaylistItems(playlistType, items, startIndex);
                }
            }
            else
            {
                WifiRemote.LogMessage("No MpExtended action defined", WifiRemote.LogType.Warn);
            }
        }
开发者ID:johanj,项目名称:WifiRemote,代码行数:48,代码来源:MpExtendedMessageHandler.cs

示例11: Starting_a_socket_server

		public void Starting_a_socket_server()
		{
			_startingEventReceived = new Future<ServerStarting>();
			_runningEventReceived = new Future<ServerRunning>();

			_input = new ChannelAdapter();
			_connection = _input.Connect(x =>
			{
				x.AddConsumerOf<ServerStarting>()
					.UsingConsumer(_startingEventReceived.Complete)
					.HandleOnCallingThread();

				x.AddConsumerOf<ServerRunning>()
					.UsingConsumer(_runningEventReceived.Complete)
					.HandleOnCallingThread();
			});

			_uri = new Uri("tcp://0.0.0.0:8008");

			_server = new SocketServer(_uri, _input);
			_server.Start();
		}
开发者ID:Nangal,项目名称:Stact,代码行数:22,代码来源:SocketServer_Specs.cs

示例12: Connect_Server

 // WPF의 연결버튼에 대한 클릭 이벤트
 private void Connect_Server(object sender, RoutedEventArgs e)
 {
     // 버튼의 값이 '연결' 일 경우
     // 서버와의 연결을 위한 프로세스가 작동한다.
     if((((Button)sender).Content).Equals("연결"))
     {
         if (HOST_IP.Text == null)
         {
             MessageBox.Show("아이피를 입력해주세요.");
         }
         else
         {
             server = new SocketServer(HOST_IP.Text);
             server.Connect();
             if (server.isConnected())
             {
                 // 연결에 성공할 경우, 상태를 나타내주는 표시등의 색과 버튼의 내용 등의 설정을 변경한다.
                 // 아이피를 넣는 곳을 읽기전용으로 만드는 이유는 아이피 변경 불가 및 방향키 인식의 오류를 방지하기 위함이다.
                 CONNECT_STATUS.Fill = Brushes.LawnGreen;
                 RESULT_OF_CONNECT.Text = "연결에 성공하였습니다.";
                 HOST_IP.SetValue(TextBox.IsReadOnlyProperty, true);
                 BUTTON.Content = "끊기";
             }
         }
     }
     // 그렇지 않을 경우, 서버와의 연결을 끊기위한 것으로 간주하고 처리한다.
     else
     {
         if(server.isConnected())
         {
             server.sendMsg("Close");
             server.Close();
             CONNECT_STATUS.Fill = Brushes.Red;
             RESULT_OF_CONNECT.Text = "IP를 입력한 후, 연결버튼을 누르세요.";
             HOST_IP.SetValue(TextBox.IsReadOnlyProperty, false);
             BUTTON.Content = "연결";
         }
     }
 }
开发者ID:Ohmry,项目名称:Univ-Projects,代码行数:40,代码来源:MainWindow.xaml.cs

示例13: HandleMovingPicturesMessage

        /// <summary>
        /// Handle an MovingPictures 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 HandleMovingPicturesMessage(Newtonsoft.Json.Linq.JObject message, SocketServer socketServer, Deusty.Net.AsyncSocket sender)
        {
            string action = (string)message["Action"];

            if (!string.IsNullOrEmpty(action))
            {
                // Show movie details for this movie
                if (action == "moviedetails")
                {
                    string movieName = (string)message["MovieName"];
                    if (!string.IsNullOrEmpty(movieName))
                    {
                        int movieId = MovingPicturesHelper.GetMovieIdByName(movieName);
                        MovingPicturesHelper.ShowMovieDetails(movieId);
                    }
                }
                // Play a movie with MovingPictures
                else if (action == "playmovie")
                {
                    int movieId = (message["MovieId"] != null) ? (int)message["MovieId"] : -1;
                    string movieName = (string)message["MovieName"];
                    bool resume = (message["AskToResume"] != null) ? (bool)message["AskToResume"] : true;
                    int startPos = (message["StartPosition"] != null) ? (int)message["StartPosition"] : 0;

                    // Play by movie id
                    if (movieId != -1)
                    {
                        MovingPicturesHelper.PlayMovie(movieId, resume, startPos);
                    }
                    else if (!string.IsNullOrEmpty(movieName))
                    {
                        // Play by name
                        MovingPicturesHelper.PlayMovie(movieName, resume, startPos);
                    }
                }
            }
        }
开发者ID:johanj,项目名称:WifiRemote,代码行数:43,代码来源:MovingPicturesMessageHandler.cs

示例14: DualModeBeginConnect_IPAddressListToHost_Helper

 private void DualModeBeginConnect_IPAddressListToHost_Helper(IPAddress[] connectTo, IPAddress listenOn, bool dualModeServer)
 {
     int port;
     Socket socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
     using (SocketServer server = new SocketServer(_log, listenOn, dualModeServer, out port))
     {
         IAsyncResult async = socket.BeginConnect(connectTo, port, null, null);
         socket.EndConnect(async);
         Assert.True(socket.Connected);
     }
 }
开发者ID:eerhardt,项目名称:corefx,代码行数:11,代码来源:DualModeSocketTest.cs

示例15: DualModeConnect_LoopbackDnsToHost_Helper

 public void DualModeConnect_LoopbackDnsToHost_Helper(IPAddress listenOn, bool dualModeServer)
 {
     int port;
     Socket socket = new Socket(SocketType.Stream, ProtocolType.Tcp);
     using (SocketServer server = new SocketServer(_log, listenOn, dualModeServer, out port))
     {
         socket.Connect("localhost", port);
         Assert.True(socket.Connected);
     }
 }
开发者ID:eerhardt,项目名称:corefx,代码行数:10,代码来源:DualModeSocketTest.cs


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