protected virtual void OnChanged(CollabrifyEventArgs e) { try { if (HttpRequestDone != null) { HttpRequestDone.Invoke(e); } else { Debug.WriteLine("Changed event is null"); } } catch { Debug.WriteLine("OnChanged exception..."); } } // OnChanged
} // getReqStream // ------------------------------------------------------------------------- private void GetResponseCallback(IAsyncResult asynchronousResult) { try { HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState; HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult); //to read server response Stream streamResponse = response.GetResponseStream(); try { collabrify_resp_pb = Serializer.DeserializeWithLengthPrefix <CollabrifyResponse_PB>(streamResponse, PrefixStyle.Base128, 0); returned_secondary_pb = null; if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.ADD_EVENT_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_AddEvent_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.ADD_PARTICIPANT_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_AddParticipant_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.ADD_TO_BASE_FILE_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_AddToBaseFile_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.CREATE_OR_GET_USER) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_CreateOrGetUser_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.CREATE_SESSION_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_CreateSession_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.CREATE_SESSION_WITH_BASE_FILE_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_CreateSessionWithBaseFile_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.DELETE_ALL_SESSIONS_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_DeleteAllSessions_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.DELETE_OLD_SESSIONS_REQUEST) { // TODO: DELETE OLD SESSIONS?? // returned_secondary_pb = Serializer.DeserializeWithLengthPrefix<Response_DeleteAllSessions_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.DELETE_SESSION_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_DeleteSession_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.DELETE_USER) { // TODO: DELETE USER?? // returned_secondary_pb = Serializer.DeserializeWithLengthPrefix<Response_DeleteSession_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.END_SESSION_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_EndSession_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_BASE_FILE_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetBaseFile_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_CURRENT_ORDER_ID_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetCurrentOrderID_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_EVENT_BATCH_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetEventBatch_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_EVENT_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetEvent_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_FROM_BASE_FILE_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetFromBaseFile_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_LAST_EVENT_BY_PARTICIPANT_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetLastEventByParticipant_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_NOTIFICATION_ID_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetNotificationID_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_PARTICIPANT_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetParticipant_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.GET_SESSION_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_GetSession_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.LIST_ACCOUNTS_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_ListAccounts_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.LIST_SESSIONS_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_ListSessions_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.PREVENT_FURTHER_JOINS_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_PreventFurtherJoins_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.REMOVE_PARTICIPANT_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_RemoveParticipant_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.REQUEST_TYPE_NOT_SET) { // TODO } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.UPDATE_NOTIFICATION_ID_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_UpdateNotificationID_PB>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.UPDATE_USER) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_UpdateUser>(streamResponse, PrefixStyle.Base128, 0); } else if (collabrify_req_pb.request_type == CollabrifyRequestType_PB.WARMUP_REQUEST) { returned_secondary_pb = Serializer.DeserializeWithLengthPrefix <Response_Warmup_PB>(streamResponse, PrefixStyle.Base128, 0); } // invokes an event that is returned to the cliend object. CollabrifyEventArgs e = new CollabrifyEventArgs(collabrify_resp_pb, returned_secondary_pb, collabrify_req_pb.request_type); try { if (HttpRequestDone != null) { HttpRequestDone.Invoke(e); } else { Debug.WriteLine("Changed event is null"); } } // try catch { Debug.WriteLine("OnChanged exception..."); } // catch } // try catch (Exception e) { System.Diagnostics.Debug.WriteLine(LOG_TAG + " Error:\nMessage: " + e.Message.ToString() + "\ndata: " + e.Data.ToString() + "\n -- \n" + e.StackTrace.ToString()); } // catch // Close the stream object streamResponse.Close(); // Release the HttpWebResponse response.Close(); } // try catch (WebException e) { System.Diagnostics.Debug.WriteLine(LOG_TAG + " Error:\nMessage: " + e.Message.ToString() + "\ndata: " + e.Data.ToString() + "\n -- \n" + e.StackTrace.ToString()); } // catch } // GetResponseCallback