public void Handle(IGluonSession session, TransferClaim request) { LOG.Info("Recieved lot host request... "); if (request.Type != Protocol.Gluon.Model.ClaimType.LOT) { session.Write(new TransferClaimResponse { Status = TransferClaimResponseStatus.REJECTED, Type = request.Type, ClaimId = request.ClaimId, EntityId = request.EntityId }); return; } var lot = Lots.TryHost(request.EntityId, session); if (lot == null) { session.Write(new TransferClaimResponse { Status = TransferClaimResponseStatus.REJECTED, Type = request.Type, ClaimId = request.ClaimId, EntityId = request.EntityId }); return; } if (Lots.TryAcceptClaim((int)request.EntityId, request.ClaimId, request.SpecialId, request.FromOwner, request.Action)) { session.Write(new TransferClaimResponse { Status = TransferClaimResponseStatus.ACCEPTED, Type = request.Type, ClaimId = request.ClaimId, EntityId = request.EntityId }); } else { session.Write(new TransferClaimResponse { Status = TransferClaimResponseStatus.CLAIM_NOT_FOUND, Type = request.Type, ClaimId = request.ClaimId, EntityId = request.EntityId }); } }
public void ReleaseAvatarClaim(IVoltronSession session) { if (session.GetAttribute("currentLot") == null) { return; } lock (_Visitors) _Visitors.Remove(session.AvatarId); //We need to keep currentLot because we need to process the Leave action //session.SetAttribute("currentLot", null); SyncNumVisitors(); if (Context.JobLot) { //tell the matchmaker we aren't connected. CityConnection.Write(new MatchmakerNotify() { Mode = MatchmakerNotifyType.RemoveAvatar, AvatarID = session.AvatarId, LotID = Context.Id & 0x3FFFFFFF }); } InBackground(() => { using (var db = DAFactory.Get) { //return claim to the city we got it from. if ((bool)(session.GetAttribute("returnClaim") ?? true)) { db.AvatarClaims.Claim(session.AvatarClaimId, Config.Call_Sign, (string)session.GetAttribute("cityCallSign"), 0); } else { db.AvatarClaims.Delete(session.AvatarClaimId, Config.Call_Sign); } } if (session.GetAttribute("visitId") != null) { var id = (int)session.GetAttribute("visitId"); using (var da = DAFactory.Get) { da.LotVisits.Leave(id); } } }); }
public void Handle(IGluonSession session, ShardShutdownRequest request) { //todo: how to handle partial shard shutdown? //if there are two separate cities, sure they can both shut down separately and the lot server will not need a "full" shutdown. //...assuming they dont want to upgrade the software! in this case, reconnecting to the upgraded city server without upgrading ourselves //could prove to be an issue! //just assume for now that lot servers are for a single shard each. var server = Kernel.Get <LotServer>(); Lots.Shutdown().ContinueWith(x => { if (x.Result) { //shutdown complete. Send a response! session.Write(new ShardShutdownCompleteResponse { ShardId = request.ShardId }); server.Shutdown(); //actually shut down the server server.SignalInternalShutdown(request.Type); } else { //shutdown already started likely. } }); }
public void ReleaseLotClaim() { //tell our city that we're no longer hosting this lot. if (CityConnection != null) { try { CityConnection.Write(new TransferClaim() { Type = Protocol.Gluon.Model.ClaimType.LOT, ClaimId = Context.ClaimId, EntityId = ((Context.Id & 0x40000000) > 0) ? (int)Context.Id : Context.DbId, FromOwner = Config.Call_Sign }); }catch (Exception ex) { LOG.Error(ex, "Unable to inform city of lot " + Context.DbId + " claim release"); } } //if this lot still has any avatar claims, kill them at least so the user's access to the game isn't limited until server restart. using (var da = DAFactory.Get()) { da.AvatarClaims.RemoveRemaining(Config.Call_Sign, Context.Id); da.LotClaims.Delete(Context.ClaimId, Config.Call_Sign); } }
public void Handle(IGluonSession session, HealthPing ping) { session.Write(new HealthPingResponse { CallId = ping.CallId, PoolHash = HostPool.PoolHash }); }
public void Handle(IGluonSession session, TransferClaim request) { if (request.Type != Protocol.Gluon.Model.ClaimType.LOT) { //what? session.Write(new TransferClaimResponse { Status = TransferClaimResponseStatus.REJECTED, Type = request.Type, ClaimId = request.ClaimId, EntityId = request.EntityId }); return; } Lots.TryClose(request.EntityId, request.ClaimId); try { using (var db = DAFactory.Get()) { db.LotClaims.Delete(request.ClaimId, request.FromOwner); } } catch (Exception e) { //probably already unclaimed. do nothing. } }
public void Handle(IGluonSession session, RequestClientSession request) { //Respond asking for a gluon challenge session.Write(new RequestChallenge() { CallSign = session.CallSign, PublicHost = session.PublicHost, InternalHost = session.InternalHost }); }
public void Handle(IGluonSession session, RequestChallengeResponse challenge) { var rawSession = ((CityConnection)session); var answer = ChallengeResponse.AnswerChallenge(challenge.Challenge, Secret); session.Write(new AnswerChallenge { Answer = answer }); }
public async void Handle(IGluonSession session, DataServiceWrapperPDU packet) { try //data service throws exceptions (SecurityException, etc) when invalid requests are made. These should not crash the server... { if (packet.Body is cTSOTopicUpdateMessage) { //Client wants to update a value in the data service var update = packet.Body as cTSOTopicUpdateMessage; DataService.ApplyUpdate(update, session); List <uint> resultDotPath = new List <uint>(); foreach (var item in update.DotPath) { resultDotPath.Add(item); if (item == packet.RequestTypeID) { break; } } try { var result = await DataService.SerializePath(resultDotPath.ToArray()); if (result != null) { session.Write(new DataServiceWrapperPDU() { SendingAvatarID = packet.SendingAvatarID, RequestTypeID = packet.RequestTypeID, Body = result }); } } catch (Exception e) { //TODO //keep this silent for now - bookmarks tend to spam errors. } } } catch (Exception e) { LOG.Error(e, "Gluon DataService request failed!"); } }
public void Handle(IGluonSession session, RequestTask task) { var shardId = new Nullable <int>(); if (task.ShardId > 0) { shardId = task.ShardId; } var id = TaskEngine.Run(new TaskRunOptions() { Task = task.TaskType, Shard_Id = shardId, Parameter = JsonConvert.DeserializeObject(task.ParameterJson) }); session.Write(new RequestTaskResponse() { CallId = task.CallId, TaskId = id }); }