Skip to content

Instantly share code, notes, and snippets.

@maxmonax
Created July 27, 2018 09:49
Show Gist options
  • Save maxmonax/be049e1d80ab87ef6525572289dcf853 to your computer and use it in GitHub Desktop.
Save maxmonax/be049e1d80ab87ef6525572289dcf853 to your computer and use it in GitHub Desktop.
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