void LogDataReceived(object sender, BayeuxConnectionEventArgs e) { IJSonWriter output = new JSonWriter(true); output.Write(e.Message); Console.WriteLine("Response: {0}", output); Console.WriteLine(); }
void LogChatEventReceived(object sender, BayeuxConnectionEventArgs e) { string channel = e.Message["channel"].StringValue; if (channel == "/chat/demo" && e.Message.Contains("data")) { Console.WriteLine("Chat message: {0} said: {1}", e.Message["data"]["user"].StringValue, e.Message["data"]["chat"].StringValue); } if (channel == "/chat/members" && e.Message.Contains("data")) { Console.WriteLine("Chat members:"); foreach (var member in e.Message["data"].ArrayItems) { Console.WriteLine(" - {0}", member.StringValue); } } }
void LogConnectionFailed(object sender, BayeuxConnectionEventArgs e) { Console.WriteLine("HTTP status: {0} ({1})", e.StatusCode, e.StatusDescription); Console.WriteLine("Exception: {0}", e.Exception); }
void ConnectionFailed(object sender, BayeuxConnectionEventArgs e) { waiter.Signal(false); }
void DataReceived(object sender, BayeuxConnectionEventArgs e) { waiter.Signal(true); }
/// <summary> /// Helper method to fire DataFailed event. /// </summary> protected virtual void OnDataFailed(BayeuxConnectionEventArgs e) { Event.Invoke(DataFailed, this, e); }
/// <summary> /// Helper method to fire ResponseReceived event. /// </summary> protected virtual void OnResponseReceived(BayeuxConnectionEventArgs e) { Event.Invoke(ResponseReceived, this, e); }
private void ConnectionOnResponseReceived(object sender, BayeuxConnectionEventArgs bayeuxConnectionEventArgs) { var serverMessages = JArray.Parse(bayeuxConnectionEventArgs.Data); foreach (var message in serverMessages) { ProcessMessage((JObject)message); } }
private void ConnectionOnDisconnected(object sender, BayeuxConnectionEventArgs bayeuxConnectionEventArgs) { OnDisconnected(); }
private void ConnectionOnConnectionFailed(object sender, BayeuxConnectionEventArgs bayeuxConnectionEventArgs) { OnConnectTimeout(); }
/// <summary> /// Helper method to fire ResponseReceived event. /// </summary> protected virtual void OnResponseReceived(BayeuxConnectionEventArgs e) { Event.Invoke(ResponseReceived, this, e); }
/// <summary> /// Helper method to fire DataFailed event. /// </summary> protected virtual void OnDataFailed(BayeuxConnectionEventArgs e) { Event.Invoke(DataFailed, this, e); }