Fix a few
This commit is contained in:
parent
3befb74114
commit
a0ca1882d8
@ -10,7 +10,7 @@ namespace Example
|
|||||||
{
|
{
|
||||||
internal class Notifier : IDisposable
|
internal class Notifier : IDisposable
|
||||||
{
|
{
|
||||||
private bool _enabled;
|
private volatile bool _enabled;
|
||||||
private Queue<NotificationMessage> _queue;
|
private Queue<NotificationMessage> _queue;
|
||||||
private ManualResetEvent _waitHandle;
|
private ManualResetEvent _waitHandle;
|
||||||
|
|
||||||
@ -65,7 +65,8 @@ namespace Example
|
|||||||
public void Notify (NotificationMessage message)
|
public void Notify (NotificationMessage message)
|
||||||
{
|
{
|
||||||
lock (((ICollection) _queue).SyncRoot) {
|
lock (((ICollection) _queue).SyncRoot) {
|
||||||
_queue.Enqueue (message);
|
if (_enabled)
|
||||||
|
_queue.Enqueue (message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace Example
|
|||||||
{
|
{
|
||||||
using (var nf = new Notifier ())
|
using (var nf = new Notifier ())
|
||||||
using (var ws = new WebSocket ("ws://echo.websocket.org"))
|
using (var ws = new WebSocket ("ws://echo.websocket.org"))
|
||||||
//using (var ws = new WebSocket ("wss://echo.websocket.org"))
|
//using (var ws = new WebSocket ("wss://echo.websocket.org")) // For Secure Connection
|
||||||
//using (var ws = new WebSocket ("ws://localhost:4649/Echo"))
|
//using (var ws = new WebSocket ("ws://localhost:4649/Echo"))
|
||||||
//using (var ws = new WebSocket ("wss://localhost:4649/Echo"))
|
//using (var ws = new WebSocket ("wss://localhost:4649/Echo"))
|
||||||
//using (var ws = new WebSocket ("ws://localhost:4649/Echo?name=nobita"))
|
//using (var ws = new WebSocket ("ws://localhost:4649/Echo?name=nobita"))
|
||||||
@ -21,7 +21,7 @@ namespace Example
|
|||||||
//using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita"))
|
//using (var ws = new WebSocket ("ws://localhost:4649/Chat?name=nobita"))
|
||||||
//using (var ws = new WebSocket ("ws://localhost:4649/チャット?name=のび太"))
|
//using (var ws = new WebSocket ("ws://localhost:4649/チャット?name=のび太"))
|
||||||
{
|
{
|
||||||
/* WebSocket events */
|
/* Setting WebSocket events */
|
||||||
ws.OnOpen += (sender, e) => ws.Send ("Hi, there!");
|
ws.OnOpen += (sender, e) => ws.Send ("Hi, there!");
|
||||||
|
|
||||||
ws.OnMessage += (sender, e) =>
|
ws.OnMessage += (sender, e) =>
|
||||||
@ -51,23 +51,23 @@ namespace Example
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
ws.Log.Level = LogLevel.Trace;
|
ws.Log.Level = LogLevel.Trace;
|
||||||
#endif
|
#endif
|
||||||
// Per-message Compression
|
// Setting Per-message Compression
|
||||||
//ws.Compression = CompressionMethod.Deflate;
|
//ws.Compression = CompressionMethod.Deflate;
|
||||||
|
|
||||||
/* Secure Connection
|
/* For Secure Connection
|
||||||
ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => {
|
ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => {
|
||||||
ws.Log.Debug (String.Format ("\n{0}\n{1}", certificate.Issuer, certificate.Subject));
|
ws.Log.Debug (String.Format ("\n{0}\n{1}", certificate.Issuer, certificate.Subject));
|
||||||
return true; // If the server cert is valid
|
return true; // If the server cert is valid
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// HTTP Authentication (Basic/Digest)
|
// For HTTP Authentication (Basic/Digest)
|
||||||
//ws.SetCredentials ("nobita", "password", false); // Digest
|
//ws.SetCredentials ("nobita", "password", false); // Digest
|
||||||
|
|
||||||
// Origin
|
// Setting Origin
|
||||||
//ws.Origin = "http://echo.websocket.org";
|
//ws.Origin = "http://echo.websocket.org";
|
||||||
|
|
||||||
// Cookies
|
// Setting Cookies
|
||||||
//ws.SetCookie (new Cookie ("nobita", "\"idiot, gunfighter\""));
|
//ws.SetCookie (new Cookie ("nobita", "\"idiot, gunfighter\""));
|
||||||
//ws.SetCookie (new Cookie ("dora", "tanuki"));
|
//ws.SetCookie (new Cookie ("dora", "tanuki"));
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ namespace Example
|
|||||||
|
|
||||||
Console.WriteLine ("\nType \"exit\" to exit.\n");
|
Console.WriteLine ("\nType \"exit\" to exit.\n");
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.Sleep (500);
|
Thread.Sleep (1000);
|
||||||
Console.Write ("> ");
|
Console.Write ("> ");
|
||||||
var msg = Console.ReadLine ();
|
var msg = Console.ReadLine ();
|
||||||
if (msg == "exit")
|
if (msg == "exit")
|
||||||
|
@ -10,7 +10,7 @@ namespace Example1
|
|||||||
{
|
{
|
||||||
internal class Notifier : IDisposable
|
internal class Notifier : IDisposable
|
||||||
{
|
{
|
||||||
private bool _enabled;
|
private volatile bool _enabled;
|
||||||
private Queue<NotificationMessage> _queue;
|
private Queue<NotificationMessage> _queue;
|
||||||
private ManualResetEvent _waitHandle;
|
private ManualResetEvent _waitHandle;
|
||||||
|
|
||||||
@ -65,7 +65,8 @@ namespace Example1
|
|||||||
public void Notify (NotificationMessage message)
|
public void Notify (NotificationMessage message)
|
||||||
{
|
{
|
||||||
lock (((ICollection) _queue).SyncRoot) {
|
lock (((ICollection) _queue).SyncRoot) {
|
||||||
_queue.Enqueue (message);
|
if (_enabled)
|
||||||
|
_queue.Enqueue (message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace Example1
|
|||||||
|
|
||||||
Console.WriteLine ("\nType \"exit\" to exit.\n");
|
Console.WriteLine ("\nType \"exit\" to exit.\n");
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread.Sleep (500);
|
Thread.Sleep (1000);
|
||||||
Console.Write ("> ");
|
Console.Write ("> ");
|
||||||
var msg = Console.ReadLine ();
|
var msg = Console.ReadLine ();
|
||||||
if (msg == "exit")
|
if (msg == "exit")
|
||||||
|
Loading…
Reference in New Issue
Block a user