Permalink
Browse files

Pusher.OnClose/Open placeholders

  • Loading branch information...
1 parent 5db37e1 commit 53f334a44ec1e3b2e3683c0ea2d29a22af1bc70b @rzhw rzhw committed Apr 27, 2011
Showing with 31 additions and 8 deletions.
  1. +31 −8 PusherClientDotNet/Pusher.cs
@@ -99,19 +99,16 @@ public void Connect()
connectionTimeout.Start();
}).Start();
- ws.OnData += (sender, e) =>
- {
- OnMessage(e);
- };
+ ws.OnData += (sender, e) => OnMessage(e);
ws.OnClose += (sender, e) =>
{
- // window.clearTimeout(connectionTimeout);
- // self.onclose.apply(self, arguments);
+ connectionTimeout.Stop();
+ OnClose();
};
ws.OnOpen += (sender, e) =>
{
- // window.clearTimeout(connectionTimeout);
- // self.onopen.apply(self, arguments);
+ connectionTimeout.Stop();
+ OnOpen();
};
this.connection = ws;
@@ -239,6 +236,32 @@ public void RetryConnect()
this.retry_counter = this.retry_counter + 1;
}
+ public void OnClose()
+ {
+ //this.global_channel.dispatch('close', null);
+ Pusher.Log("Pusher : Socket closed");
+ if (this.connected)
+ {
+ //this.send_local_event("pusher:connection_disconnected", {});
+ if (Pusher.allow_reconnect)
+ {
+ Pusher.Log("Pusher : Connection broken, trying to reconnect");
+ this.Reconnect();
+ }
+ }
+ else
+ {
+ //this.send_local_event("pusher:connection_failed", {});
+ this.RetryConnect();
+ }
+ this.connected = false;
+ }
+
+ public void OnOpen()
+ {
+ //this.global_channel.dispatch('open', null);
+ }
+
// Pusher defaults
const string VERSION = "1.8.3";

0 comments on commit 53f334a

Please sign in to comment.