// ------------------------------------------------------------------------- /// <summary> /// makes a warmup request to the server and returns a response object in the form of RESPONSE_ /// </summary> public static void make_request(CollabrifyClient c, HttpRequest__Object obj, string name, List<string> tags, string password, int participantLimit = 0) { CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB(); req_pb.request_type = CollabrifyRequestType_PB.CREATE_SESSION_WITH_BASE_FILE_REQUEST; Random rd = new Random(); Request_CreateSession_PB cs_pb = new Request_CreateSession_PB(); cs_pb.owner_display_name = c.participant.getDisplayName(); cs_pb.session_name = name; if (password != "") { cs_pb.session_password = password; } foreach (string s in tags) { cs_pb.session_tag.Add(s); } cs_pb.account_gmail = c.getAccountGmail(); cs_pb.access_token = c.getAccessToken(); cs_pb.owner_display_name = c.participant.getDisplayName(); cs_pb.owner_user_id = c.participant.getUserID(); if (participantLimit > 0) { cs_pb.participant_limit = participantLimit; } cs_pb.owner_notification_id = "0"; cs_pb.owner_notification_type = NotificationMediumType_PB.COLLABRIFY_CLOUD_CHANNEL; byte[] baseFile = null; HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb, baseFile); try { request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request); } catch (WebException e) { System.Diagnostics.Debug.WriteLine(" -- EXCEPTION THROWN \n" + e.Message); } }
public void getReqStream(IAsyncResult result) { try { HttpWebRequest request = (HttpWebRequest)result.AsyncState; Stream postStream = request.EndGetRequestStream(result); CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB(); req_pb.request_type = CollabrifyRequestType_PB.CREATE_SESSION_REQUEST; MemoryStream ms = new MemoryStream(); Serializer.SerializeWithLengthPrefix<CollabrifyRequest_PB>(ms, req_pb, PrefixStyle.Base128, 0); Request_CreateSession_PB ls_pb = new Request_CreateSession_PB(); ls_pb.account_gmail = "*****@*****.**"; ls_pb.access_token = "82763BDBCA"; ls_pb.session_tag.Add("none"); ls_pb.session_name = "this is a test session5"; ls_pb.owner_display_name = "Jack"; ls_pb.owner_gmail = "*****@*****.**"; ls_pb.owner_notification_id = "Jack"; ls_pb.owner_notification_type = NotificationMediumType_PB.COLLABRIFY_CLOUD_CHANNEL; MemoryStream ms2 = new MemoryStream(); Serializer.SerializeWithLengthPrefix<Request_CreateSession_PB>(ms2, ls_pb, PrefixStyle.Base128, 0); byte[] byteArr = ms.ToArray(); postStream.Write(byteArr, 0, byteArr.Length); System.Diagnostics.Debug.WriteLine("writing ms... size: " + byteArr.Length.ToString()); byteArr = ms2.ToArray(); postStream.Write(byteArr, 0, byteArr.Length); System.Diagnostics.Debug.WriteLine("writing ms2... size: " + byteArr.Length.ToString()); postStream.Close(); request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request); } catch (WebException e) { System.Diagnostics.Debug.WriteLine("web exception"); } }