protected override void Awake() { base.Awake(); if (_instance != this) { return; } settings = NetworkSettings.LoadSettings(Application.dataPath + Path.DirectorySeparatorChar + "network_settings"); if (ShowBuild.GetBuildType() == "CONSOLE") { isMaster = false; } isMaster = false; if (isMaster) { Network.InitializeServer(1, 25552, false); } else { Debug.Log("connecting: " + Network.Connect(NetworkController.settings.hostIp, 25552)); Debug.Log("Sono fuori dalla connect"); } }
protected override void Awake() { base.Awake(); //Set app settings from build type string buildType = ShowBuild.GetBuildType(); switch (buildType) { case "DEV": appSettings = new DevAppSettings(); break; case "PRODUCTION": appSettings = new ProductionAppSettings(); break; case "SMALL": appSettings = new SmallAppSettings(); break; case "CUSTOM": case "CONSOLE": try { XmlSerializer ser = new XmlSerializer(typeof(DefaultAppSettings)); TextReader reader = new StreamReader(Application.dataPath + Path.DirectorySeparatorChar + "build_settings"); appSettings = (DefaultAppSettings)ser.Deserialize(reader); } catch (System.Exception e) { appSettings = new DefaultAppSettings(); Debug.Log("error reading custom settings, reverting to default " + e.Message); } break; default: appSettings = new DefaultAppSettings(); break; } //only make keyboard input for console if (buildType != "CONSOLE") { UserInput = InputController.Create(appSettings.inputController); backupInput = InputController.Create(appSettings.inputControllerBackup); } else { UserInput = InputController.Create(typeof(KeyboardInputController)); } AdminInput = InputController.Create(typeof(AdminInputController)) as AdminInputController; //if(buildType != "CONSOLE") Screen.SetResolution(appSettings.xResolution, appSettings.yResolution, appSettings.fullscreen); AdminInput.SwapInputMethod += SwapInputMethod; }
protected override void Awake() { base.Awake(); if (_instance != this) { return; } settings = NetworkSettings.LoadSettings(Application.dataPath + Path.DirectorySeparatorChar + "network_settings"); // Init Transport using default values. NetworkTransport.Init(); // Create a connection config and add a Channel. ConnectionConfig config = new ConnectionConfig(); channelId = config.AddChannel(QosType.Reliable); // Create a topology based on the connection config. HostTopology topology = new HostTopology(config, 10); // Create a host based on the topology we just created, and bind the socket to port 12345. hostId = NetworkTransport.AddHost(topology, 25552); ///changed if (ShowBuild.GetBuildType() == "CONSOLE") { isMaster = false; } if (isMaster) { byte error; connectionId = NetworkTransport.Connect(hostId, NetworkController.settings.clientIp, 25552, 0, out error); Debug.Log(connectionId + ":connection" + hostId + ":hostId" + channelId + ":channelId and ip:\t" + NetworkController.settings.clientIp); Debug.Log(error); sender = sendToClient(2.0f); StartCoroutine(sender); // Network.InitializeServer(1, 25552, false); } else { byte error; connectionId = NetworkTransport.Connect(hostId, NetworkController.settings.hostIp, 25552, 0, out error); Debug.Log(connectionId + ":connection" + hostId + ":hostId" + channelId + ":channelId and ip:\t" + NetworkController.settings.clientIp); Debug.Log(error); //We used to connect to the server in this new case its the other way arround. //Debug.Log("connecting: " + Network.Connect(NetworkController.settings.hostIp, 25552)); } }
public IEnumerator Start() { yield return(new WaitForSeconds(delay)); string buildType = ShowBuild.GetBuildType(); if (loadConsole || buildType == "CONSOLE") { Application.LoadLevel("Console"); } else { AudioController.Instance.PlaySelectMusic(); StartCoroutine(launchScreen.StartSequence(() => AppController.Instance.LoadCarSelect())); } }
public void Start() { string buildType = ShowBuild.GetBuildType(); if (buildType == "CONSOLE") { gameObject.SetActive(false); Destroy(gameObject); return; } tempCachePath = Application.temporaryCachePath; if (RemoteAdminController.Instance == this) { StaticInstance = this; } receivedMessages = new Queue <string>(); debugLog = new Queue <string>(); httpServer = new HttpServer(8087); httpServer.RootPath = Application.streamingAssetsPath + "/Admin"; httpServer.OnGet += (sender, e) => { var req = e.Request; var res = e.Response; var path = req.RawUrl; if (path == "/") { path += "index.html"; } if (path.StartsWith("/Screenshots")) { res.ContentType = "image/jpeg"; res.ContentEncoding = System.Text.Encoding.UTF8; int id = -1; try { char[] p = new char[] { '/' }; id = int.Parse(path.Split(p)[2]); byte[] data = System.IO.File.ReadAllBytes(tempCachePath + "/" + id + ".jpg"); res.WriteContent(data); return; } catch (System.Exception ex) { debugLog.Enqueue("Error loading screenshot " + id + ": " + ex.Message); res.StatusCode = (int)HttpStatusCode.NotFound; res.Abort(); return; } } var content = httpServer.GetFile(path); if (content == null) { res.StatusCode = (int)HttpStatusCode.NotFound; return; } if (path.EndsWith(".html")) { res.ContentType = "text/html"; res.ContentEncoding = System.Text.Encoding.UTF8; } else if (path.EndsWith(".javascript")) { res.ContentType = "text/javascript"; res.ContentEncoding = System.Text.Encoding.UTF8; } else if (path.EndsWith(".css")) { res.ContentType = "text/css"; res.ContentEncoding = System.Text.Encoding.UTF8; } else if (path.EndsWith(".png")) { res.ContentType = "image/png"; res.ContentEncoding = System.Text.Encoding.UTF8; } else if (path.EndsWith(".jpg")) { res.ContentType = "image/jpeg"; res.ContentEncoding = System.Text.Encoding.UTF8; } //httpServer.Log.Debug("writing resonse: " + res.ToString()); res.WriteContent(content); }; //httpServer.Log.File = Application.streamingAssetsPath + "/Admin/http.log"; //httpServer.Log.Level = LogLevel.Debug; httpServer.Start(); server = new WebSocketServer(8088); // server.OnConnect += (sender, e) => { // debugLog.Enqueue("remote client connected"); // }; //server.Log.File = Application.streamingAssetsPath + "/Admin/websocket.log"; //server.Log.Level = LogLevel.Debug; server.AddWebSocketService <AdminScreenSocket>("/api"); server.Start(); Debug.Log("started server"); }
void Start() { buildString = buildString + ShowBuild.GetBuildNumber() + " " + ShowBuild.GetBuildType(); }