private void connectToServer() { if (!io.IsConnected) { io.Connect(); } while (!io.IsConnected) { Thread.Sleep(100); Logger.debug("Trying to connect"); } Logger.debug("Connection complete"); gameHasStarted = false; //io.On(Strings.serverMessage.events.CONNECT, (SocketIOEvent obj) => //{ // //Dictionary<string,string> info = new Dictionary<string,string>(); // //info["username"] = UserManager.instance.user.username; // //info["password"] = UserManager.instance.user.password; // //JSONObject jObj = new JSONObject(info); // //io.Emit(Strings.serverMessage.events.REQUEST_NEW_GAME,jObj); //} //); io.On(Constants.serverMessage.events.DISCONNECT, onDisconnect); io.On(Constants.serverMessage.events.NOTIFY_FOUND_GAME, (SocketIOEvent obj) => { Logger.debug("A game found"); GameInfo info = new GameInfo(); info.fillWithRawObj(obj); gameHasStarted = true; onGameFound(info); }); Dictionary <string, string> data = new Dictionary <string, string>(); //data[Strings.serverMessage.events.REQUEST_NEW_GAME_PARAMS.USERNAME] = UserManager.instance.user.username; //data[Strings.serverMessage.events.REQUEST_NEW_GAME_PARAMS.PASSWORD] = UserManager.instance.user.password; data[Constants.serverMessage.events.REQUEST_NEW_GAME_PARAMS.TOKEN] = Constants.HEADERS.SESSION + player.user.getAccessToken(); JSONObject jObj = new JSONObject(data); bool reqComplete = false; io.On(Constants.serverMessage.events.REQUEST_NEW_GAME_SUC, (SocketIOEvent obj) => { //Logger.debug("Requesting new game is successful"); reqComplete = true; }); while (!reqComplete) { io.Emit(Constants.serverMessage.events.REQUEST_NEW_GAME, jObj); Thread.Sleep(100); } onSendComplete(); }
public void btnConnect_OnClick() { var webSocketURLFormat = "ws://{0}:{1}/socket.io/?EIO=4&transport=websocket"; socket.url = string.Format(webSocketURLFormat, ipInputField.text, portInputField.text); UpdatePlayerName(); gameSessionUI.ResetData(); socket?.Connect(); #if UNITY_EDITOR_LINUX || UNITY_STANDALONE_LINUX try { string title = string.Format(WindowTitleFormat, Application.productName, PlayerName); SetWindowTitle(title); } catch (DllNotFoundException e) { Debug.Log(e.ToString()); } #endif // ui.Show(GameUI.View.GameSessionView); }
// Update is called once per frame void Update() { if (!socket.IsConnected && Connected == false) { socket.Connect(); } }
//GameManager gameManager; void Start() { //Makes this object stay throughout the entire scene if (dontDestroyOnLoad) { DontDestroyOnLoad(transform.gameObject); } network = FindObjectOfType <NetworkManager> (); //Find the Socket Component in the Game Scene GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); //Register what kind of messages the client receives socket.On("ConnectionTest", NetTest); socket.On("JoinRoom", NetLogin); //socket.On ("Response", NetResponse); socket.Connect(); //Start Connection Test if (socket.IsConnected) { //Debug.Log ("Connected to Server!"); StartCoroutine("ConnectionTest"); } else { Debug.Log("Not Connected..."); } }
public void Connect() { socket.Connect(); startMessageText.text = "상대를 기다리는 중..."; connectButton.gameObject.SetActive(false); //connectButton.interactable = false; }
/// <summary> /// Initializes the socketIo game object and component /// </summary> IEnumerator SocketIORoutine() { while (string.IsNullOrEmpty(PlayerPrefs.GetString("socket_url"))) { yield return(null); } GameObject.Find("SocketErrorText").GetComponent <Text>().enabled = false; socketObject = new GameObject("SocketIO"); socketObject.AddComponent <SocketIOComponent>(); socket = socketObject.GetComponent <SocketIOComponent>(); socket.Url = "ws://" + PlayerPrefs.GetString("socket_url") + "/socket.io/?EIO=4&transport=websocket"; socket.On("connect", SocketConnectCb); socket.Connect(); // if no connection within appropriate time, destroy and retry yield return(new WaitForSeconds(socketTimeout)); if (!socket.socket.IsConnected) { PlayerPrefs.SetString("socket_url", ""); GameObject.Destroy(socketObject); GameObject.Find("SocketUrlInput").GetComponent <InputField>().text = ""; GameObject.Find("SocketPanel").GetComponent <CanvasGroup>().alpha = 1; GameObject.Find("SocketErrorText").GetComponent <Text>().enabled = true; StartCoroutine(SocketIORoutine()); } }
internal void Connect() { if (!isConnected()) { SktIO.Connect(); } }
public override void OnStartState(IStateMachine stateMachine, params object[] args) { base.OnStartState(stateMachine, args); this.Inject(); //userData.Load(); _socket = GameObject.FindObjectOfType <SocketIOComponent>(); if (!_socket.isConnected) { AppConfig.LoadByUrlAsync().ContinueWith(json => { var config = BaseBootStrapper.OnConfigLoaded(json); _socket.url = config.Main.LobbyAddress; _socket.Connect(); StartCoroutine(_InitNetworkReady()); }); } else { SetToNextState(); } }
// Start is called before the first frame update void Start() { #if (UNITY_2018_3_OR_NEWER) if (Permission.HasUserAuthorizedPermission(Permission.Microphone)) { } else { Permission.RequestUserPermission(Permission.Microphone); } #endif meditationSessionStarted = false; GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); socket.On("open", OpenSocket); socket.On("error", ErrorSocket); socket.On("close", CloseSocket); socket.On("authenticate", AuthenticateSocket); socket.On("authenticated", AuthenticatedSocket); socket.On("created-meditation-room", CreatedMeditationRoomSocket); socket.On("meditation-room-not-full", MeditationRoomNotFullSocket); socket.On("meditation-room-is-full", MeditationRoomIsFullSocket); socket.On("got-student-data", GotStudentDataSocket); socket.On("instructor-left-room", InstructorLeftRoomSocket); socket.Connect(); }
void Start() { // find the root game object for each target galvanometerTarget = GameObject.Find("Galvanometer"); morsecodeTarget = GameObject.Find("MorseCode"); // get the SocketIOComponent GameObject go = GameObject.Find("SocketIO"); // if the object can be found if (go != null) { // get the conponent and attach events socket = go.GetComponent <SocketIOComponent>(); if (socket != null) { // connect socket.Connect(); socket.On("hardware", OnHardware); } else { Debug.Log("No socket in scene"); } } else { Debug.Log("No SocketIO in scene"); } }
public void JoinTheGameBTN() { Socket.Connect(); MainMenuCamera.enabled = false; Instantiate(Player); MainMenu.gameObject.SetActive(false); }
void Start() { if (!connectedToServer) { socket.Connect(); loggedIn = false; } }
/// <summary> /// Connect this instance. /// </summary> internal void Connect() { if (!IsConnected()) { socket.Connect(); StartCoroutine(CheckPingTimeOut()); } }
public static void SetGameConnection() { if (GameSocket == null || GameSocket.IsConnected == false) { GameSocket = GameObject.Find("[Network Container]").GetComponent <GameClient>(); GameSocket.Connect(); } }
public void Connect() { gameManager = GetComponent <TicTacToeManager>(); socket.Connect(); startMessageText.text = "상대를 기다리는 중입니다.."; closeButton.interactable = true; // connectButton.gameObject.SetActive(false); }
// Start is called before the first frame update void Start() { if (!socket) { socket = GameObject.Find("SocketIO").GetComponent <SocketIOComponent>(); DontDestroyOnLoad(socket); socket.Connect(); } }
public void OnStartServerClicked() { socket.url = serverPath; socket.Connect(); socket.On("hello", OnHello); Debug.LogWarning("Socket URL:"); Debug.LogWarning(socket.url); return; }
public void OnClickConnect() { connectButton.interactable = false; //서버에 접속 if (socket) { socket.Connect(); } }
/// <summary> /// Connect to the server and listen for all the needed callbacks /// </summary> private void ConnectToServer() { _socketComponent.Connect(); _socketComponent.On("pong", OnPongCallback); _socketComponent.On("event_status", OnEventStatusCallback); _socketComponent.On("send_scores", OnSendPlayersCallback); _socketComponent.On("player_removed", OnPlayerRemoved); _socketComponent.On("send_player_score", OnSendPlayerScoreCallback); }
private IEnumerator ConnectAll() { yield return(null); test1.On("SUCCESS_CONNECT", (SocketIOEvent e) => { Debug.Log("test1 : " + e.ToString()); }); test1.Connect(); test2.On("SUCCESS_CONNECT", (SocketIOEvent e) => { Debug.Log("test2 : " + e.ToString()); }); test2.Connect(); }
public void OnClickConnect() { socket.Connect(); if (socket.IsConnected) { connectionState = ConnectionState.Connected; } bg_Connect.SetActive(false); bg_CreateOrJoin.SetActive(true); }
public void StartSocket() { socketIo.On("connect", OnConnect); socketIo.On("disconnect", OnDisconnect); socketIo.On("error", OnError); socketURL.interactable = false; connectBtn.sprite = disconnectIcon; socketIo.myDebugLog = myLog; socketIo.Connect(); }
void Awake() { DontDestroyOnLoad(this); //Screen.SetResolution(Screen.width,(Screen.width/3)*2,true); Screen.SetResolution(800, 480, true); if (!Socket.IsConnected) { Socket.Connect(); } }
public void Connect() { if (socket.IsConnected) { return; } waitingOnOpen = true; Debug.Log("Connecting to game lobby service..."); socket.Connect(); }
public void OnClickConnect() { connectButton.interactable = false; //서버에접속 if (socket) { socket.Connect(); //cellsObject.SetActive(true); } }
public void Start() { Debug.Log("connecting"); socket = GetComponent <SocketIOComponent>(); socket.On("open", OnConnected); socket.On("new message", OnNewMessage); socket.Connect(); }
public void Start() { GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); socket.On("connect", LogThroughput); socket.On("disconnect", LogThroughput); Debug.Log("Connecting to " + socket.url); socket.Connect(); }
private IEnumerator Start() { yield return(null); RegisterSocket(socket); socket.Connect(); yield return(new WaitForSeconds(0.5f)); var jsonStr = JsonConvert.SerializeObject(JooConfiguration.GetConfig <NetworkPlayer>()); socket.Emit("playerEnter", JSONObject.Create(jsonStr)); }
// Use this for initialization void Start() { labo.OnCombineSeed.AddListener(CombineSeed); Debug.Log("connecting...."); GameObject go = GameObject.Find("SocketIO"); socket = go.GetComponent <SocketIOComponent>(); socket.Connect(); socket.On("updateInventory", onUpdateInventory); socket.On("gridElementReceive", onGridUpdate); }
void Start() { socket.On("connect", OnSocketConnect); // socket.On ("disconnect", OnSocketDisonnect); // socket.On ("open", OnSocketOpen); // socket.On ("close", OnSocketClose); // socket.On ("error", OnSocketError); Debug.Log("Connecting socket."); socket.Connect(); }