static void Main(string[] args) { AkkaConfigurationSection section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka"); Config aconfig = section.AkkaConfig; try { _system = ActorSystem.Create("VirtualFrameworkConsole", aconfig); } catch (Exception ex) { ColorConsole.WriteLine($"Error initializig Akka:{ex.Message}".Red()); // throw; } try { IActorRef asel = _system.ActorSelection(_localUrl) .ResolveOne(TimeSpan.Zero).Result; _terminal = asel.Cast <TerminalConnectionRef>(); } catch (Exception e) { ColorConsole.WriteLine($"Error connecting to server:{e.Message}".Red()); } if (_terminal == null) { ColorConsole.WriteLine("Error connecting to server".Red()); } var shell = new Shell(); RegisterCommands(shell, true); shell.WritePrompt += ShellOnWritePrompt; shell.ShellCommandNotFound += ShellOnShellCommandNotFound; shell.PrintAlternatives += ShellOnPrintAlternatives; try { shell.RunShell(); } catch (ApplicationExitException) { _system.Terminate().Wait(); } }
public async Task DoLogin(string name, string password) { Username = name; Password = password; try { string serverHash = RootComponents.Instance.AssetLoader.GetServerHash(); if (serverHash != RootComponents.Instance.ClientHash) { MainUI.Instance.ShowMessageBox($"Client/server incompatibility: \n {serverHash} \n {RootComponents.Instance.ClientHash}", () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } } catch (Exception e) { if (e is SocketException) { MainUI.Instance.ShowMessageBox($"Can't connect to server: {e.Message}", () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } else { MainUI.Instance.ShowMessageBox($"Error: {e.Message}", () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } } _log.Info($"Logging in, login {name}, password {password}"); try { IActorRef asel = AkkaSystem.ActorSelection(MainSettings.ServerUrl) .ResolveOne(TimeSpan.Zero).Result; MainServer = asel.Cast <ConnectionRef>(); Tuple <bool, string, ServerInfo> loginInfo = await MainServer.DoLogin(name, password); if (!loginInfo.Item1) { MainUI.Instance.ShowMessageBox(loginInfo.Item2, () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); return; } UserId = loginInfo.Item3._loggedInUserId; foreach (var atype in loginInfo.Item3.AdditionalRegisteredBehaviours) { _log.Info($"Adding behavior type from plugin: {atype.Value}"); /// TYPEBEHAVIOUR.AddRegisteredType(); TYPEBEHAVIOUR.AddRegisteredTypeAndIndex(atype.Key, atype.Value); } //now start the connection process _mainClient = AkkaSystem .ActorOf(Props.Create(() => new ClientConnection(MainServer, _clientId, Guid.Parse(MainSettings.InitialScene))), "ClientConnection") .Cast <ClientConnectionRef>(); //await _mainClient.RegisterConnection(Guid.Empty, ""); } catch (Exception e) { MainUI.Instance.ShowMessageBox(e.ToString(), () => { MainUI.Instance.ShowLoginWindow(Username, Password); }); Debug.Log(e); // throw; } //start updates //if (MainSettings.UseUpdateThread) //{ // _updateInterval = MainSettings.UpdateThreadInterval; // _updateThread = new Thread(this.TickUpdaters); // _updateThread.Start(); //} }
public UserLoginActor(IActorRef actorBoundChannel) { _actorBoundChannel = actorBoundChannel.Cast <ActorBoundChannelRef>().WithRequestWaiter(this); }
public UserLoginActor(IActorRef actorBoundChannel) { _actorBoundChannel = actorBoundChannel.Cast<ActorBoundChannelRef>().WithRequestWaiter(this); }