public static void DefineServerToClientMethods() { ServerHub.WorkingInstance.ServerHubProxy.On <JObject>("SendNuntias", (nuntiasJson) => { Nuntias newNuntias = new Nuntias(nuntiasJson); if (newNuntias != null) { Console.WriteLine("SendNuntias() Called by server => " + newNuntias.Id + " " + newNuntias.ContentFileId); bool updatedNuntias = false; if (newNuntias.SenderId != Consumer.LoggedIn.Id && newNuntias.DeliveryTime == null) { newNuntias.DeliveryTime = Time.CurrentTime; updatedNuntias = true; } if (newNuntias.ContentFileId != null && newNuntias.ContentFileId.Length > 0) { if (newNuntias.ContentFileId == "deleted") { try { LocalDataFileAccess.EraseContentFile(SyncAssets.NuntiasSortedList[newNuntias.Id].ContentFileId); } catch { } } else { ServerFileRequest.DownloadAndStoreContentFile(newNuntias); } } bool?updateResult = NuntiasRepository.Instance.Update(newNuntias); if (updateResult == false) { long?result = NuntiasRepository.Instance.Insert(newNuntias); if (result == null) { return; } try { if (ConversationListPanel.MyConversationListPanel != null) { ConversationListPanel.MyConversationListPanel.RefreshConversationList(); } if (ConversationPanel.CurrentDisplayedConversationPanel.TheConversation.ConversationID == newNuntias.NativeConversationID) { ConversationPanel.CurrentDisplayedConversationPanel.ShowNuntias(newNuntias, true); } } catch { } } else if (updateResult == true) { SyncAssets.UpdateNuntias(newNuntias); } if (updatedNuntias) { ServerRequest.UpdateNuntiasStatus(newNuntias); } } } ); ServerHub.WorkingInstance.ServerHubProxy.On("SendPendingNuntias", () => { Console.WriteLine("SendPendingNuntias() Called by server. "); BackendManager.SendPendingNuntii(); } ); ServerHub.WorkingInstance.ServerHubProxy.On <long, string>("UpdateUsersActivity", (userId, userActivity) => { try { if (ConversationPanel.CurrentDisplayedConversationPanel.TheConversation.Type == "duet" && ((DuetConversation)ConversationPanel.CurrentDisplayedConversationPanel.TheConversation).OtherMember.Id == userId) { ConversationPanel.CurrentDisplayedConversationPanel.UpdateUserActivity(userActivity); } } catch { } } ); ServerHub.WorkingInstance.ServerHubProxy.On <long, string>("SomethingBeingTypedForYou", (conversationId, messageText) => { try { if (ConversationPanel.CurrentDisplayedConversationPanel.TheConversation.ConversationID == conversationId) { if (Universal.ParentForm.InvokeRequired) { Universal.ParentForm.Invoke(new Action(() => { ConversationPanel.CurrentDisplayedConversationPanel.SomethingBeingTypedLabel.Text = messageText; ConversationPanel.CurrentDisplayedConversationPanel.AdjustTypingBarSize(); })); } else { ConversationPanel.CurrentDisplayedConversationPanel.SomethingBeingTypedLabel.Text = messageText; ConversationPanel.CurrentDisplayedConversationPanel.AdjustTypingBarSize(); } } } catch (Exception ex) { Console.WriteLine("Exception in SomethingBeingTypedForYou() => : " + ex.Message); } } ); }