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.WARMUP_REQUEST;
            MemoryStream ms = new MemoryStream();
            Serializer.SerializeWithLengthPrefix<CollabrifyRequest_PB>(ms, req_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");
            }
        }
        // -------------------------------------------------------------------------
        /// <summary>
        /// makes a request to the server
        /// </summary> 
        public static void make_request(CollabrifyClient c, HttpRequest__Object obj, long id, string password)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.ADD_PARTICIPANT_REQUEST;

              Request_AddParticipant_PB cs_pb = new Request_AddParticipant_PB();
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.access_token = c.getAccessToken();
              cs_pb.participant_display_name = c.participant.getDisplayName();
              cs_pb.participant_user_id = c.participant.getUserID();
              cs_pb.participant_notification_id = c.participant.getId().ToString();
              cs_pb.participant_notification_type = NotificationMediumType_PB.COLLABRIFY_CLOUD_CHANNEL;

              cs_pb.session_id = id;
              cs_pb.session_password = password;

              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        /// <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)
        {
            /* if user isnt owner of session, dont delete the session */
              if (c.currentSessionOwner().getId() != c.participant.getId())
              {
            return;
              }

              CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.DELETE_SESSION_REQUEST;

              Request_DeleteSession_PB cs_pb = new Request_DeleteSession_PB();
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.access_token = c.getAccessToken();
              cs_pb.participant_id = c.participant.getId();
              cs_pb.session_id = c.currentSessionID();

              CollabrifyParticipant owner = c.currentSessionOwner();
              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("BeginGetRequestStream FAILED:\n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        /// <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)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.REMOVE_PARTICIPANT_REQUEST;

              Request_RemoveParticipant_PB cs_pb = new Request_RemoveParticipant_PB();
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.access_token = c.getAccessToken();
              cs_pb.session_id = c.currentSessionID();

              if (c.getSession().getIsPasswordProtected())
              {
            cs_pb.session_password = "";
              }

              cs_pb.accessing_participant_id = c.participant.getId();
              cs_pb.to_be_removed_participant_id = c.participant.getId();

              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        /// <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, List<string> tags)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.LIST_SESSIONS_REQUEST;

              Request_ListSessions_PB cs_pb = new Request_ListSessions_PB();
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.access_token = c.getAccessToken();
              foreach (string s in tags) cs_pb.session_tag.Add(s);
              cs_pb.limit_query_to_organization_account = true;
              cs_pb.use_subset_query = true;
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.access_token = c.getAccessToken();
              foreach (string s in tags)
              {
            cs_pb.session_tag.Add(s);
              }

              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        public HttpWebRequest BuildRequest(CollabrifyRequest_PB req_pb,
            object _secondary_pb = null, object _trail_info = null)
        {
            HttpWebRequest request = HttpWebRequest.CreateHttp(BASE_URI);
              request.ContentType = "application/x-www-form-urlencoded";
              request.Method = "POST";
              request.Credentials = new NetworkCredential("*****@*****.**",
                                                  "82763BDBCA");

              collabrify_req_pb = req_pb;
              secondary_pb = _secondary_pb;
              trail_info = _trail_info;

              return request;
        }
        // -------------------------------------------------------------------------
        /// <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)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.GET_EVENT_BATCH_REQUEST;

              HttpWebRequest request = obj.BuildRequest(req_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        /// <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);
              }
        }
        // -------------------------------------------------------------------------
        /// <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)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.ADD_TO_BASE_FILE_REQUEST;

              Request_AddToBaseFile_PB cs_pb = new Request_AddToBaseFile_PB();
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.access_token = c.getAccessToken();

              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        /// <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)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.CREATE_OR_GET_USER;

              Request_CreateOrGetUser_PB cs_pb = new Request_CreateOrGetUser_PB();
              cs_pb.create_if_does_not_exist = true;
              cs_pb.user_id = c.participant.getUserID();

              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              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");
            }
        }
        // -------------------------------------------------------------------------
        /// <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, long session_id, string session_password)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.GET_SESSION_REQUEST;

              Request_GetSession_PB cs_pb = new Request_GetSession_PB();
              //cs_pb.account_gmail = c.getAccountGmail();
              //cs_pb.access_token = c.getAccessToken();
              cs_pb.session_id = session_id;
              cs_pb.session_password = session_password;

              HttpWebRequest request = obj.BuildRequest(req_pb, cs_pb);

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }
        // -------------------------------------------------------------------------
        /// <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)
        {
            CollabrifyRequest_PB req_pb = new CollabrifyRequest_PB();
              req_pb.request_type = CollabrifyRequestType_PB.GET_EVENT_REQUEST;

              HttpWebRequest request = obj.BuildRequest(req_pb);

              Request_GetEvent_PB cs_pb = new Request_GetEvent_PB();
              cs_pb.access_token = c.getAccessToken();
              cs_pb.account_gmail = c.getAccountGmail();
              cs_pb.participant_id = c.participant.getId();
              cs_pb.session_id = c.getSession().getId();
              cs_pb.order_id = c.getSession().getCurrentOrderId();

              try
              {
            request.BeginGetRequestStream(new AsyncCallback(obj.getReqStream), request);
              }
              catch (WebException e)
              {
            System.Diagnostics.Debug.WriteLine("  -- EXCEPTION THROWN \n" + e.Message);
              }
        }