public bool Receive(string command, object response, long resTime) { if (command.Equals("9201")) { NPCloudReceiveParameter <string> npcloudReceiveParameter = response as NPCloudReceiveParameter <string>; NpMessageParameter obj = new NpMessageParameter(npcloudReceiveParameter.option.roomId, (int)npcloudReceiveParameter.sender, npcloudReceiveParameter.body, NpUtil.MsTimestampToDateTime(npcloudReceiveParameter.resTime)); this.mMessage(obj); return(true); } if (command.Equals("9202")) { NPCloudReceiveParameter <List <RoomMsgLog> > npcloudReceiveParameter2 = response as NPCloudReceiveParameter <List <RoomMsgLog> >; List <NpRoomMsgLog> list = new List <NpRoomMsgLog>(); foreach (RoomMsgLog roomMsgLog in npcloudReceiveParameter2.body) { DateTime sendtime = NpUtil.MsTimestampToDateTime(roomMsgLog.createdat); if (!string.IsNullOrEmpty(roomMsgLog.userid) || !string.IsNullOrEmpty(roomMsgLog.sendedmsg)) { NpRoomMsgLog item = new NpRoomMsgLog(roomMsgLog.userid, sendtime, roomMsgLog.sendedmsg); list.Add(item); } } this.mRoomMsgLog(list); return(true); } return(false); }
protected override Task OnInit(NpUtil util) { var cToken = cTokenSource.Token; var contentRoot = Path.Combine(Directory.GetCurrentDirectory()); var host = WebHost.CreateDefaultBuilder(); host.UseContentRoot(contentRoot) .UseStartup <AppWebService>() .UseUrls(App.Config.AppUrl) //Use a reverse proxy to get this to port 443 with SSL. .Build() .RunAsync(cToken); return(Task.FromResult(0)); }
private bool ForceLeave(string command, NpCloudReceiveRoomParameter response, long resTime) { if (!command.Equals("9106")) { return(false); } if (response.member_list == null) { return(true); } this.mUserList[response.room_id] = response.member_list; this.mJoinRoomList[response.room_id].MemberList = response.member_list; NpLeaveParameter obj = new NpLeaveParameter(LeaveTypeE.ForceLeave, response.room_id, response.member_left, response.owner, response.member_list, NpUtil.MsTimestampToDateTime(resTime)); this.mLeaveRoom(obj); return(true); }
private bool Join(string command, NpCloudReceiveRoomParameter response, long resTime) { if (command.Equals("9100")) { bool isNewMember = true; NpRoomParameter npRoomParameter = new NpRoomParameter(RoomJoinTypeE.Create, response.room_id, response.room_name, (RoomType)response.room_type, (int)NpCloudManager.GetInstance().UserID, isNewMember, response.owner, response.member_list, new List <RoomCondition>(), NpUtil.MsTimestampToDateTime(resTime)); if (response.room_condition != null) { npRoomParameter.RoomCondition = response.room_condition; } List <int> member_list = response.member_list; if (!this.mJoinRoomList.ContainsKey(npRoomParameter.RoomId)) { this.mJoinRoomList.Add(npRoomParameter.RoomId, npRoomParameter); this.mUserList.Add(npRoomParameter.RoomId, member_list); } else { this.mUserList[npRoomParameter.RoomId] = member_list; this.mJoinRoomList[npRoomParameter.RoomId] = npRoomParameter; } this.mJoinRoom(npRoomParameter); return(true); } if (command.Equals("9102")) { NpRoomParameter npRoomParameter2 = new NpRoomParameter(RoomJoinTypeE.RoomJoin, response.room_id, response.room_name, (RoomType)response.room_type, response.member_joined, response.is_new_member != 0, response.owner, response.member_list, new List <RoomCondition>(), NpUtil.MsTimestampToDateTime(resTime)); if (response.room_condition != null) { npRoomParameter2.RoomCondition = response.room_condition; } List <int> member_list2 = response.member_list; if (!this.mJoinRoomList.ContainsKey(npRoomParameter2.RoomId)) { this.mJoinRoomList.Add(npRoomParameter2.RoomId, npRoomParameter2); this.mUserList.Add(npRoomParameter2.RoomId, member_list2); } else { this.mUserList[npRoomParameter2.RoomId] = member_list2; this.mJoinRoomList[npRoomParameter2.RoomId] = npRoomParameter2; } this.mJoinRoom(npRoomParameter2); return(true); } return(false); }
private bool RemoveRoom(string command, NpCloudReceiveRoomParameter response, long resTime) { if (command.Equals("9101")) { if (this.mJoinRoomList.ContainsKey(response.room_id)) { this.mJoinRoomList.Remove(response.room_id); } if (this.mUserList.ContainsKey(response.room_id)) { this.mUserList.Remove(response.room_id); } NpLeaveParameter obj = new NpLeaveParameter(LeaveTypeE.DeleteRoom, response.room_id, 0, 0, new List <int>(), NpUtil.MsTimestampToDateTime(resTime)); this.mLeaveRoom(obj); return(true); } return(false); }
protected override Task OnRun(NpUtil util) { return(Task.FromResult(0)); }
protected override Task OnDispose(NpUtil util) { cTokenSource.Cancel(); return(Task.FromResult(0)); }
protected override async Task OnRun(NpUtil util) { await UpdateAndReturnIfDbIsUp(); }
protected async override Task OnDispose(NpUtil util) { await Task.FromResult(0); }
protected async override Task OnRun(NpUtil util) { System.Globalization.CultureInfo.CurrentCulture.ClearCachedData(); await Task.FromResult(0); }
protected async override Task OnInit(NpUtil util) { await Task.FromResult(0); }