0

Comet-Style Notification

Hi,

I made a C# application which works with the Periodic Polling style method.I am having problem with Comet - Style request. I'm able to send request and receive the response, however I can only receive the response ONCE. I don't know the way to handle the event or notification when the server push message to the client.

Please guide me.
Code for Comet - Style request

public void GetNotification()
{

string session_KeepAlive = messageServer + "/v1/session/keepalive";
CookieContainer cookieJar = new CookieContainer();
HttpWebRequest session_KeepAlive_Request = WebRequest.Create("http://" + session_KeepAlive + "?&sid=" + sessionId + "&notifyServerToken=" + 1 +
"&oauth_consumer_key=" + oauth_consumer_key + "&oauth_signature_method=" + oauth_signature_method + "&oauth_nonce=" + oauth_nonce +
"&oauth_timestamp=" + oauth_timestamp + "&oauth_signature=" + oauth_signature + "&oauth_version=" + oauth_version + "&oauth_token=" +
oauth_token) as HttpWebRequest;
session_KeepAlive_Request.CookieContainer = cookieJar;
session_KeepAlive_Request.Method = "Put";
msgInformation msg = new msgInformation();
using (HttpWebResponse response = session_KeepAlive_Request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(response.GetResponseStream());
string str = reader.ReadToEnd();
foreach (Cookie cookie in response.Cookies)
{
cookieJar.Add(cookie);
}

}
string Notify_realm = _notifyServer + "/v1/pushchannel/" + primaryLoginId;
string format = "json";
int idle = 300000;
HttpWebRequest request = WebRequest.Create("http://" + Notify_realm + "?&sid=" + sessionId + "&seq=" + 0 + "&format=" + format + "&idle=" + idle +
"&oauth_consumer_key=" + oauth_consumer_key + "&oauth_signature_method=" + oauth_signature_method + "&oauth_nonce=" + oauth_nonce +
"&oauth_timestamp=" + oauth_timestamp + "&oauth_signature=" + oauth_signature + "&oauth_version=" + oauth_version + "&oauth_token=" +
oauth_token) as HttpWebRequest;
request.CookieContainer = cookieJar;
request.Method = "get";
using (HttpWebResponse session_response = request.GetResponse() as HttpWebResponse)
{
// Get the response stream
StreamReader reader = new StreamReader(session_response.GetResponseStream());
string str = reader.ReadToEnd();
-
-
-
-
}
}


Thanks

by
0 Replies

Recent Posts

in Messenger IM SDK