Created
July 27, 2018 09:49
-
-
Save maxmonax/be049e1d80ab87ef6525572289dcf853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Net; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Data; | |
using System.Windows.Documents; | |
using System.Windows.Input; | |
using System.Windows.Media; | |
using System.Windows.Media.Imaging; | |
using System.Windows.Navigation; | |
using System.Windows.Shapes; | |
using System.Net.Sockets; | |
using WebSocketSharp; | |
namespace WebSockTest | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
private WebSocket ws; | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
ws = new WebSocket("ws://149.154.159.241:3333"); | |
ws.OnMessage += (sender, e) => | |
Console.WriteLine("recv: " + e.Data); | |
ws.OnClose += (sender, e) => { | |
Console.WriteLine("sock closed: " + e.Code); | |
}; | |
ws.OnError += (sender, e) => { | |
Console.WriteLine("sock error: " + e.Message); | |
}; | |
ws.Connect(); | |
} | |
private void Button_Click(object sender, RoutedEventArgs e) | |
{ | |
ws.Send("{}"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment