public LotConnectionRegulator([Named("City")] AriesClient cityClient, [Named("Lot")] AriesClient lotClient, IClientDataService dataService) { City = cityClient; City.AddSubscriber(this); Client = lotClient; Client.AddSubscriber(this); DataService = dataService; City.AddSubscriber(this); AddState("Disconnected") .Transition() .OnData(typeof(JoinLotRequest)).TransitionTo("SelectLot") .Default(); AddState("SelectLot").OnlyTransitionFrom("Disconnected"); AddState("FindLot").OnlyTransitionFrom("SelectLot").OnData(typeof(FindLotResponse)).TransitionTo("FoundLot"); AddState("FoundLot").OnlyTransitionFrom("FindLot"); AddState("OpenSocket") .OnData(typeof(AriesConnected)).TransitionTo("SocketOpen") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("FoundLot"); AddState("SocketOpen") .OnData(typeof(RequestClientSession)).TransitionTo("RequestClientSession") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("OpenSocket"); AddState("RequestClientSession") .OnData(typeof(HostOnlinePDU)).TransitionTo("HostOnline") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("SocketOpen"); AddState("HostOnline").OnlyTransitionFrom("RequestClientSession"); AddState("PartiallyConnected") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnData(typeof(FSOVMTickBroadcast)).TransitionTo("LotCommandStream") .OnData(typeof(FSOVMDirectToClient)).TransitionTo("LotCommandStream") .OnlyTransitionFrom("HostOnline"); AddState("LotCommandStream") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnData(typeof(FSOVMTickBroadcast)).TransitionTo("LotCommandStream") .OnData(typeof(FSOVMDirectToClient)).TransitionTo("LotCommandStream"); AddState("UnexpectedDisconnect"); AddState("Disconnect") .OnData(typeof(AriesDisconnected)) .TransitionTo("Disconnected"); }
public GluonHost(GluonHostPool pool, string callSign, IKernel kernel, ServerConfiguration config) { this.Pool = pool; this.CallSign = callSign; this.Client = new AriesClient(Pool.Kernel); Callbacks = new Dictionary <Guid, TaskCompletionSource <IGluonCall> >(); Client.AddSubscriber(this); Router = new AriesPacketRouter(); Router.On <RequestClientSession>((session, message) => { session.Write(new RequestChallenge() { CallSign = CallSign, PublicHost = PublicHost, InternalHost = InternalHost }); }); Router.On <RequestChallengeResponse>((session, message) => { var challenge = (RequestChallengeResponse)message; var answer = ChallengeResponse.AnswerChallenge(challenge.Challenge, config.Secret); session.Write(new AnswerChallenge { Answer = answer }); }); Router.On <AnswerAccepted>((session, message) => { OnAuthenticated(); }); }
public CityConnection(IKernel kernel, LotServerConfigurationCity config, LotServerConfiguration lotServerConfig) { LotServerConfig = lotServerConfig; CityConfig = config; Client = new AriesClient(kernel); Client.AddSubscriber(this); _Router = kernel.Get <IAriesPacketRouter>(); }
public ClientDataService(IModelSerializer serializer, FSO.Content.Content content, IKernel kernel) : base(serializer, content) { AddProvider(kernel.Get <ClientAvatarProvider>()); AddProvider(kernel.Get <ClientLotProvider>()); AddProvider(kernel.Get <ClientCityProvider>()); CityClient = kernel.Get <AriesClient>("City"); CityClient.AddSubscriber(this); //When a new object is made, this data will be requested automatically SetDefaultDataStruct(typeof(Avatar), MaskedStruct.SimPage_Main); PollInterval = GameThread.SetInterval(PollTopics, 5000); }
public CreateASimRegulator([Named("City")] AriesClient cityClient) { City = cityClient; City.AddSubscriber(this); AddState("Idle") .Default() .Transition() .OnData(typeof(RSGZWrapperPDU)) .TransitionTo("CreateSim"); AddState("CreateSim").OnlyTransitionFrom("Idle"); AddState("Waiting") .OnlyTransitionFrom("CreateSim") .OnData(typeof(CreateASimResponse)) .TransitionTo("ProcessResponse"); AddState("ProcessResponse").OnlyTransitionFrom("Waiting"); AddState("Error").OnlyTransitionFrom("ProcessResponse"); AddState("Success").OnlyTransitionFrom("ProcessResponse"); }
public DatabaseService([Named("City")] AriesClient cityClient) { CityClient = cityClient; CityClient.AddSubscriber(this); }
public CityConnectionRegulator(CityClient cityApi, [Named("City")] AriesClient cityClient, IDatabaseService db, IClientDataService ds, IKernel kernel, IShardsDomain shards) { CityApi = cityApi; Client = cityClient; Client.AddSubscriber(this); DB = db; DataService = ds; Shards = shards; AddState("Disconnected") .Default() .Transition() .OnData(typeof(ShardSelectorServletRequest)) .TransitionTo("SelectCity"); AddState("SelectCity") .OnlyTransitionFrom("Disconnected", "Reconnecting"); AddState("ConnectToCitySelector") .OnData(typeof(ShardSelectorServletResponse)) .TransitionTo("CitySelected") .OnlyTransitionFrom("SelectCity"); AddState("CitySelected") .OnData(typeof(ShardSelectorServletResponse)) .TransitionTo("OpenSocket") .OnlyTransitionFrom("ConnectToCitySelector"); AddState("OpenSocket") .OnData(typeof(AriesConnected)).TransitionTo("SocketOpen") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("CitySelected"); AddState("SocketOpen") .OnData(typeof(RequestClientSession)).TransitionTo("RequestClientSession") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("OpenSocket"); AddState("RequestClientSession") .OnData(typeof(HostOnlinePDU)).TransitionTo("HostOnline") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("SocketOpen"); AddState("HostOnline").OnlyTransitionFrom("RequestClientSession"); AddState("PartiallyConnected") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnData(typeof(ShardSelectorServletRequest)).TransitionTo("CompletePartialConnection") .OnlyTransitionFrom("HostOnline"); AddState("CompletePartialConnection").OnlyTransitionFrom("PartiallyConnected"); AddState("AskForAvatarData") .OnData(typeof(LoadAvatarByIDResponse)).TransitionTo("ReceivedAvatarData") .OnlyTransitionFrom("PartiallyConnected", "CompletePartialConnection"); AddState("ReceivedAvatarData").OnlyTransitionFrom("AskForAvatarData"); AddState("AskForCharacterData").OnlyTransitionFrom("ReceivedAvatarData"); AddState("ReceivedCharacterData").OnlyTransitionFrom("AskForCharacterData"); AddState("Connected") .OnData(typeof(AriesDisconnected)).TransitionTo("UnexpectedDisconnect") .OnlyTransitionFrom("ReceivedCharacterData"); AddState("UnexpectedDisconnect"); AddState("Disconnect") .OnData(typeof(AriesDisconnected)) .TransitionTo("Disconnected"); AddState("Reconnect") .OnData(typeof(AriesDisconnected)) .TransitionTo("Reconnecting"); AddState("Reconnecting") .OnData(typeof(ShardSelectorServletRequest)) .TransitionTo("SelectCity") .OnlyTransitionFrom("Reconnect"); GameThread.SetInterval(() => { if (Client.IsConnected) { Client.Write(new KeepAlive()); } }, 10000); //keep alive every 10 seconds. prevents disconnection by aggressive NAT. }