コード例 #1
0
 public void Handle(IGluonSession session, HealthPing ping)
 {
     session.Write(new HealthPingResponse {
         CallId   = ping.CallId,
         PoolHash = HostPool.PoolHash
     });
 }
コード例 #2
0
        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.
            }
        }
コード例 #3
0
 public void Handle(IGluonSession session, TransferClaimResponse claimResponse)
 {
     if (claimResponse.Type == Protocol.Gluon.Model.ClaimType.LOT)
     {
         Lots.OnTransferClaimResponse(claimResponse);
     }
 }
コード例 #4
0
        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.
                }
            });
        }
コード例 #5
0
ファイル: LotServerPicker.cs プロジェクト: LinSianTing/FreeSO
 public void UpdateServerAdvertisement(IGluonSession session, AdvertiseCapacity request)
 {
     lock (Servers)
     {
         var state = GetState(session);
         if (state == null)
         {
             state = new LotServerState {
                 Session = session
             };
             Servers.Add(state);
             if (ServersByCallsign.ContainsKey(session.CallSign))
             {
                 ServersByCallsign[session.CallSign] = state;
             }
             else
             {
                 ServersByCallsign.Add(session.CallSign, state);
             }
         }
         state.Session       = session; //can be hot-swapped if we re-establish connection. TODO: verify and look for race conditions
         state.MaxLots       = request.MaxLots;
         state.CurrentLots   = request.CurrentLots;
         state.CpuPercentAvg = request.CpuPercentAvg;
         state.RamAvaliable  = request.RamAvaliable;
         state.RamUsed       = request.RamUsed;
     }
 }
コード例 #6
0
        public async void Handle(IGluonSession session, NotifyLotRoommateChange packet)
        {
            //recieved from a lot server to notify of another lot's roommate change.
            using (var da = DAFactory.Get())
            {
                var lot = da.Lots.Get(packet.LotId);
                if (lot == null)
                {
                    return;              //lot missing
                }
                DataService.Invalidate <FSO.Common.DataService.Model.Lot>(lot.location);

                //if online, notify the lot
                var lotOwned = da.LotClaims.GetByLotID(lot.lot_id);
                if (lotOwned != null)
                {
                    var lotServer = LotServers.GetLotServerSession(lotOwned.owner);
                    if (lotServer != null)
                    {
                        //immediately notify lot of new roommate
                        lotServer.Write(packet);
                    }
                }
                else
                {
                    //try force the lot open
                    //we don't need to send any packets in this case - the lot fully restores object ownership from db.
                    var result = await Lots.TryFindOrOpen(lot.location, 0, NullSecurityContext.INSTANCE);
                }
            }
        }
コード例 #7
0
ファイル: LotHost.cs プロジェクト: HarryFreeMyLand/newso
        public LotHostEntry TryHost(int id, IGluonSession cityConnection)
        {
            lock (Lots)
            {
                if (AwaitingShutdown)
                {
                    return(null);
                }
                if (Lots.Values.Count >= Config.Max_Lots)
                {
                    //No room
                    return(null);
                }

                if (Lots.ContainsKey(id))
                {
                    return(null);
                }

                var ctnr = Kernel.Get <LotHostEntry>();
                var bind = Kernel.GetBindings(typeof(LotHostEntry));
                ctnr.CityConnection = cityConnection;
                Lots.Add(id, ctnr);
                CityConnections.LotCount = (short)Lots.Count;
                return(ctnr);
            }
        }
コード例 #8
0
 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
     });
 }
コード例 #9
0
        public void Handle(IGluonSession session, RequestChallengeResponse challenge)
        {
            var rawSession = ((CityConnection)session);
            var answer     = ChallengeResponse.AnswerChallenge(challenge.Challenge, Secret);

            session.Write(new AnswerChallenge {
                Answer = answer
            });
        }
コード例 #10
0
 public async void Handle(IGluonSession session, MatchmakerNotify packet)
 {
     switch (packet.Mode)
     {
     case MatchmakerNotifyType.RemoveAvatar:
         Matchmaker.RemoveAvatar(packet.LotID, packet.AvatarID);
         break;
     }
 }
コード例 #11
0
 public async void Handle(IGluonSession session, CityNotify packet)
 {
     try
     {
         await Nhoods.TickNeighborhoods();
     } catch (Exception e)
     {
         LOG.Error("Neighborhood Task Failed: " + e.ToString());
     }
 }
コード例 #12
0
ファイル: LotServerPicker.cs プロジェクト: LinSianTing/FreeSO
 public void RegisterShutdown(IGluonSession session)
 {
     lock (ServersShutdown)
     {
         ServersShutdown.Remove(session);
         if (ServersShutdown.Count == 0)
         {
             AllServersShutdown.SetResult(true);
         }
     }
 }
コード例 #13
0
ファイル: LotServerPicker.cs プロジェクト: LinSianTing/FreeSO
 public IGluonSession GetLotServerSession(string callSign)
 {
     lock (Servers)
     {
         IGluonSession  result = null;
         LotServerState state  = null;
         if (ServersByCallsign.TryGetValue(callSign, out state))
         {
             result = state.Session;
         }
         return(result);
     }
 }
コード例 #14
0
        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
                });
            }
        }
コード例 #15
0
 public void Handle(IGluonSession session, SendCityMail packet)
 {
     try
     {
         foreach (var mail in packet.Items)
         {
             SendEmail(mail, true);
         }
     }
     catch (Exception e)
     {
         LOG.Error("Failed to send an ingame email from another service: " + e.ToString());
     }
 }
コード例 #16
0
        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!");
            }
        }
コード例 #17
0
        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
            });
        }
コード例 #18
0
 public void Handle(IGluonSession session, TuningChanged request)
 {
     Lots.UpdateTuning(request.UpdateInstantly);
 }
コード例 #19
0
 public void Handle(IGluonSession session, AdvertiseCapacity capacity)
 {
     PickingEngine.UpdateServerAdvertisement(session, capacity);
 }
コード例 #20
0
ファイル: LotServerPicker.cs プロジェクト: LinSianTing/FreeSO
        private LotServerState GetState(IGluonSession session)
        {
            var server = Servers.FirstOrDefault(x => x.Session == session);

            return(server);
        }
コード例 #21
0
 public void Handle(IGluonSession session, ShardShutdownCompleteResponse request)
 {
     Picker.RegisterShutdown(session);
 }
コード例 #22
0
        public void Handle(IGluonSession session, AnswerAccepted accepted)
        {
            var rawSession = ((CityConnection)session);

            rawSession.AuthenticationEstablished();
        }
コード例 #23
0
 public void Handle(IGluonSession session, RequestLotClientTermination request)
 {
     Lots.TryDisconnectClient(request.LotId, request.AvatarId);
 }
コード例 #24
0
 public void Handle(IGluonSession session, NotifyLotRoommateChange request)
 {
     Lots.NotifyRoommateChange(request.LotId, request.AvatarId, request.ReplaceId, request.Change);
 }