예제 #1
0
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("message", TestMessage);
    }
예제 #2
0
 public void Start()
 {
     socket = gameObject.GetComponent<SocketIOComponent>();
     socket.On("smarttouch-start", SmartTouch);
     socket.On("smarttouch-end", SmartTouch);
     checkJSON.readJson();
 }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     GameObject go = GameObject.Find("SocketIO");
     socket = go.GetComponent<SocketIOComponent>();
     transform.position = startPosition;
     socket.Emit("LoadMap");
 }
예제 #4
0
파일: Bat.cs 프로젝트: alciakng/WormsClient
    void Start()
    {
        sc = GameObject.Find ("ServerConnect").GetComponent<ServerConnect> ();
        Socket = sc.Socket;

        tc = GameObject.Find ("TurnController").GetComponent<TurnController> ();
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        Debug.Log ("ConfigScreen start with ipAddr= "+ipAddr+":"+port);
        GameObject SocketIOobj = GameObject.Find ("SocketIO");
        sockio = (SocketIOComponent)SocketIOobj.GetComponent("SocketIOComponent");

        sockio.Close();

        if (PlayerPrefs.HasKey("IPAddress")) {

            ipAddr =  PlayerPrefs.GetString("IPAddress");
            Debug.Log ("PlayerPrefs has IPAddress = "+ipAddr);
        } else {
            ipAddr = sockio.ipAddr;
        }
        if (PlayerPrefs.HasKey("Port")) {

            port =  PlayerPrefs.GetString("Port");
            Debug.Log ("PlayerPrefs has Port = "+port);
        } else {
            port = sockio.port;
        }

        connectStatus.text = sockio.IsConnected ? "Connected" : "Not Connected";
        ipAddrInpField.text = ipAddr;
        portInpField.text = port;

        Debug.Log ("ConfigScreen start now ending with ipAddr= "+ipAddr+":"+port+" and connectStatus = "+connectStatus.text);

        //Text ipTextVal = ipAddrTextField.GetComponent<Text>();
        //GameObject ipAddrTextFieldPlaceholder = GameObject.Find("IpAddr-Placeholder");
        //Text placeholder = ipAddrTextFieldPlaceholder.GetComponent<Text>();
        //ipTextVal.text = ipAddr;
        //placeholder.text = ipAddr;
    }
예제 #6
0
	//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...");
		}

	}
예제 #7
0
파일: Chat.cs 프로젝트: SuwalskiKarol/oor
	void Start () 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		myscript = go.GetComponent<ectScript>();
		socket.On ("talk", ChatMessage);
	}
예제 #8
0
    public void Initialize()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.Connect();

        // Register callbacks
        socket.On("message", OnMessage);

        // Send first contact to server
        socket.Emit("connection");

        // Log in
        Dictionary<string,string> login = new Dictionary<string,string>();
        login["username"] = "******";
        socket.Emit("login", new JSONObject(login));

        /*
        client = new Client(url);

        client.Opened += OnSocketOpened;
        client.Message += SocketMessage;
        client.SocketConnectionClosed += SocketConnectionClosed;
        client.Error +=SocketError;

        client.Connect();
        */
    }
예제 #9
0
    // Use this for initialization
    void Start()
    {
        rb = this.GetComponent<Rigidbody> ();
        gameManager = GameObject.Find ("GameManager").GetComponent<GameManager> ();
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open", TestOpen);
        socket.On("gyro", (message) =>
        {
           JSONObject json =  message.data;
            JSONObject pitchJSON = json.GetField("beta");
            pitchAxis = float.Parse(pitchJSON.ToString())/180;
            JSONObject rollJSON = json.GetField("gamma");
            rollAxis = float.Parse(rollJSON.ToString())/180;
            JSONObject yawJSON = json.GetField("alpha");
            //yawAxis = float.Parse(yawJSON.ToString());
            //yawAxis = (yawAxis - 180) / 360;

            //Debug.Log("pitch: "+pitchAxis+" yaw: " +yawAxis +" Roll "+ rollAxis);

        });
        socket.On("speed",(message) =>
         {
            AmbientSpeed = float.Parse (message.data.GetField("speed").ToString());
        });

        socket.On("error", TestError);
        socket.On("close", TestClose);
    }
예제 #10
0
    // Use this for initialization
    void Start()
    {
        rb = GetComponent<Rigidbody2D> ();

        sc = GameObject.Find ("ServerConnect").GetComponent<ServerConnect> ();
        tc = GameObject.Find ("TurnController").GetComponent<TurnController> ();
        Socket = sc.Socket;
    }
예제 #11
0
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //コントローラーの命令が入ってきたら処理する。(1、idを特定し、オブジェクトを特定 2、特定したオブジェクトのコンポーネントに命令)
        socket.On("move",CheckID);
    }
예제 #12
0
    void Awake()
    {
        PlayFabSettings.TitleId = "9C78";
        GameObject go = GameObject.Find("SocketIO");
        socketIO = go.GetComponent<SocketIOComponent>();

        DontDestroyOnLoad (socketIO);
    }
예제 #13
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();
        socket.On ("rgb",changeBackgroundRGB);

        _guiText = guiText.GetComponent<Text> ();
    }
예제 #14
0
	void Start () {
		DontDestroyOnLoad (gameObject);
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		socket.On ("connection", Connection);
		socket.On("loginconfirm", LoginConfirm);
	}
예제 #15
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open",Opend);
        socket.On("power",PowerReact);
    }
예제 #16
0
    void Awake()
    {
        DontDestroyOnLoad(this);

        sc = GameObject.Find ("ServerConnect").GetComponent<ServerConnect> ();
        mc = GameObject.Find ("MenuController").GetComponent<MenuController> ();
        Socket = sc.Socket;
    }
예제 #17
0
	void Start () 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		myscript = go.GetComponent<ectScript>();
		socket.Emit("LoadMap");
		socket.On("swapAllPlayer",swapAllPlayer);

	}
예제 #18
0
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        pan = transform.position.x;
        pitch = transform.position.y;

        updatePosition("created");
    }
예제 #19
0
 private bool Init()
 {
     if (Instance != null)
     {
         Destroy(this);
         return(false);
     }
     Instance = this;
     return(true);
 }
예제 #20
0
    // Use this for initialization
    void Start ()
	{
	    _gameboard = FindObjectOfType<Gameboard>();

        GameObject go = GameObject.Find("SocketIO");
        _socket = go.GetComponent<SocketIOComponent>();
        _socket.On("login", connectCallback);
        _socket.On("move", moveCallback);
        Debug.Log("Connecting");
    }
예제 #21
0
    // Use this for initialization
    void Start()
    {
        //socket.io approach
        //retrieve socket component
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        nodeList = new Dictionary<string, Node>(); //create a new dictionary

        socket.On("result", NodeListUpdate); //event listener waiting for the results of the node queries
    }
예제 #22
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open", TestOpen);
        socket.On("message",OnMessage);
        socket.On("welcome",OnWelcome);
        socket.On("error", TestError);
        socket.On("close", TestClose);
    }
예제 #23
0
	void Start () 
	{
		Name = " ";
		DontDestroyOnLoad (gameObject);
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		socket.On("error", ServerError);
		socket.On("close", ServerClose);
		transform.position = startPosition;
		rend = GetComponent<Renderer>();
	}
예제 #24
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //新しくログインしてきたら、CreateNewを起動
        socket.On("new_player",CreateNewPlayer);

        //誰かがページを離れたら、オブジェクトが消える。
        socket.On("player_exit",RemovePlayer);
    }
예제 #25
0
    public void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        socket.On("open", Open);
        socket.On("wait", Wait);
        socket.On("roomready", Roomready);
        socket.On("needwait", NeedWait);
        socket.On("error", Error);
        socket.On("close", Close);
    }
예제 #26
0
    // Use this for initialization
    void Start()
    {
        InitUI ();

        //same old, same old
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //register for events via coordinated string keys
        //there are some defaults, like connect, open, close
        socket.On("connect", ConnectedToServer);
    }
예제 #27
0
	public void Start()
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		socket.On("open", TestOpen);
		socket.On("boop", TestBoop);
		socket.On("error", TestError);
		socket.On("close", TestClose);
		
		StartCoroutine("BeepBoop");
	}
예제 #28
0
	// Use this for initialization
	void Start () {
		//ws://localhost:4567/socket.io/?EIO=4&transport=websocket
		//GameObject go = GameObject.Find("SocketIO");
		socket = GameObject.FindObjectOfType<SocketIOComponent>();
		//socket.Connect ();

		socket.On("open", OnSocketOpen);
		socket.On("error", OnSocketError);
		socket.On("chat message", ChatMessage);

		//StartCoroutine(TestCoroutine());
	}
예제 #29
0
    void StartWebsocket()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();


        socket.On("acceleration", OnAcceleration);
        socket.On("steering", OnSteering);
        //socket.On("open", TestOpen);
        /*socket.On("error", TestError);
        socket.On("close", TestClose);*/

    }
	// Use this for initialization
	void Start () {
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		Debug.Log ("Adding callbacks");
		socket.On("connect", Connect);
		socket.On("updateBlob", UpdateUser);
		socket.On("newBlob", AddUser);
		socket.On ("removeBlob", DeleteUser);

		socket.Connect ();

	}
예제 #31
0
        public void Start()
        {
            if (autoConnect)
            {
                Connect();

                GameObject        go   = GameObject.Find("SocketIO");
                SocketIOComponent sock = (SocketIOComponent)go.GetComponent(typeof(SocketIOComponent));

                sock.On("move_forward_Utkarsh", (SocketIOEvent e) => {
                    Debug.Log("Utkarsh move forward");
                });
            }
        }
예제 #32
0
	public void Start() 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
        
        txt = this.gameObject.GetComponent<Text>(); 

		socket.On("sendname", OnSendName);
		socket.On("randomnumber",OnRandomNumber);
		socket.On("welcome",OnWelcome);
		socket.On("error", TestError);
		socket.On("close", TestClose);

	}
예제 #33
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");

        socket = go.GetComponent <SocketIO.SocketIOComponent>();

        socket.On("open", socketConnected);

        socket.On("do flight", doFlight);

        // transform.position = start.position;

        pos = transform.position;
        rot = transform.rotation;
        // Debug.Log("Position " + pos + " and the rotation " + rot);
    }
예제 #34
0
        public void Awake()
        {
            if (singleton)
            {
                if (instance == null)
                {
                    instance = this;
                }
                else
                {
                    Destroy(gameObject);
                    return;
                }
                DontDestroyOnLoad(gameObject);
            }

            encoder  = new Encoder();
            decoder  = new Decoder();
            parser   = new Parser();
            handlers = new Dictionary <string, List <Action <SocketIOEvent> > > ();
            ackList  = new List <Ack> ();
            sid      = null;
            packetId = 0;

            ws            = new WebSocket(url);
            ws.OnOpen    += OnOpen;
            ws.OnMessage += OnMessage;
            ws.OnError   += OnError;
            ws.OnClose   += OnClose;
            wsConnected   = false;

            eventQueueLock = new object();
            eventQueue     = new Queue <SocketIOEvent> ();

            ackQueueLock = new object();
            ackQueue     = new Queue <Packet> ();

            connected = false;

                        #if SOCKET_IO_DEBUG
            if (debugMethod == null)
            {
                debugMethod = Debug.Log;
            }
            ;
                        #endif
        }
예제 #35
0
    /// <summary>
    /// Handles the player join packet, it will spawn a player on the possition given by the server.
    /// </summary>
    /// <param name="e"></param>
    /// <param name="socket"></param>
    /// <param name="networkManager"></param>
    public PlayerJoin(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
        : base(e, socket, networkManager)
    {
        this.clientId = data["socketId"];

        this.x = PacketUtils.FromPacketString(data["spawnLocationX"]);
        this.y = PacketUtils.FromPacketString(data["spawnLocationY"]);
        this.z = PacketUtils.FromPacketString(data["spawnLocationZ"]);

        this.headRotationX = PacketUtils.FromPacketString(data["headRotationX"]);
        this.headRotationY = PacketUtils.FromPacketString(data["headRotationY"]);
        this.headRotationZ = PacketUtils.FromPacketString(data["headRotationZ"]);
        this.headRotationW = PacketUtils.FromPacketString(data["headRotationW"]);

        this.playerTypeId = int.Parse(data["playerType"]);
        this.isMain       = networkManager.IsMain(this.clientId);

        HandlePacket();
    }
예제 #36
0
 // Use this for initialization
 void Start()
 {
     io          = GameObject.Find("SocketIO").GetComponent <SocketIO.SocketIOComponent>();
     test_script = GameObject.Find("ConnectServer").GetComponent <TestSocketIO>();
 }
예제 #37
0
 /// <summary>
 /// A pretty empty packet, it's just our clientId the server will do the rest.
 /// </summary>
 /// <param name="socket">The socket</param>
 /// <param name="networkManager">The network manager</param>
 public PlayerJoinBuilder(SocketIO.SocketIOComponent socket, NetworkManager networkManager) :
     base(socket, networkManager, "PlayerJoin")
 {
     Send();
 }
예제 #38
0
    void Start()
    {
        io = GetComponent <SocketIO.SocketIOComponent>();
        dodgeballManager = transform.parent.GetComponentInChildren <dodgeballManager>();

        io.On("joined-game", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data = e.data;
            Debug.Log("Joined game " + data);
        });
        io.On("player-position-update", (SocketIO.SocketIOEvent e) =>
        {
            try
            {
                JSONObject data = e.data;
                string playerID = data.GetField("id").ToString();

                JSONObject playerPos = data.GetField("position");
                Vector3 newPos       = new Vector3(
                    float.Parse(playerPos.GetField("x").ToString()),
                    float.Parse(playerPos.GetField("y").ToString()),
                    float.Parse(playerPos.GetField("z").ToString())
                    );

                JSONObject playerRot = data.GetField("rotation");
                Quaternion newRot    = new Quaternion(
                    float.Parse(playerRot.GetField("x").ToString()),
                    float.Parse(playerRot.GetField("y").ToString()),
                    float.Parse(playerRot.GetField("z").ToString()),
                    float.Parse(playerRot.GetField("w").ToString())
                    );

                player p = getPlayer(playerID);
                if (p != null)
                {
                    p.newPos = newPos;
                    p.newRot = newRot;
                }
            }
            catch (Exception err)
            {
                Debug.LogError("player-position-update-exception: " + err);
            }
        });
        io.On("dodgeball-thrown", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data   = e.data;
            JSONObject posObj = data.GetField("position");
            JSONObject dirObj = data.GetField("direction");
            int ID            = int.Parse(data.GetField("ID").ToString());
            string playerID   = data.GetField("playerID").ToString();

            Vector3 position = new Vector3(
                float.Parse(posObj.GetField("x").ToString()),
                float.Parse(posObj.GetField("y").ToString()),
                float.Parse(posObj.GetField("z").ToString())
                );
            Vector3 direction = new Vector3(
                float.Parse(dirObj.GetField("x").ToString()),
                float.Parse(dirObj.GetField("y").ToString()),
                float.Parse(dirObj.GetField("z").ToString())
                );
            dodgeballManager.onNetworkThrowBall(position, direction);
            getPlayer(playerID).network.onThrowDodgeball();
        });
        io.On("dodgeball-pickup", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data = e.data;
            string playerID = data.GetField("playerID").ToString();

            player foundPlayer = getPlayer(playerID);
            foundPlayer.network.onPickupDodgeball();
        });
        io.On("player-join", (SocketIO.SocketIOEvent e) =>
        {
            Debug.Log("new player join");
            JSONObject data = e.data;

            player newPlayer     = new player();
            newPlayer.id         = data.GetField("playerID").ToString();
            GameObject playerObj = GameObject.Instantiate(playerPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
            newPlayer.transform  = playerObj.transform;
            newPlayer.network    = playerObj.GetComponent <networkPlayerController>();
            otherPlayers.Add(newPlayer);
        });
        io.On("player-disconnect", (SocketIO.SocketIOEvent e) =>
        {
            JSONObject data = e.data;
            string id       = data.GetField("id").ToString();
            player p        = otherPlayers.Find(x => x.id == id);
            GameObject.Destroy(p.transform.gameObject);
            otherPlayers.Remove(p);
        });
        io.On("player-death", (SocketIO.SocketIOEvent e) =>
        {
            Debug.Log("player death");
        });
    }
예제 #39
0
 public UpdateSeeker(SocketIO.SocketIOEvent e, SocketIO.SocketIOComponent socket, NetworkManager networkManager)
     : base(e, socket, networkManager)
 {
     this.player = networkManager.GetPlayerFromClientId(data["clientId"]);
     this.HandlePacket();
 }