コード例 #1
0
ファイル: GeneratePrefabs.cs プロジェクト: ehackb/EHackVisual
    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
ファイル: statusPlayer.cs プロジェクト: carl03q/salsipuedes
 // 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
ファイル: ServerInterface.cs プロジェクト: cjcurrie/HOPELite
    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
ファイル: Donkey.cs プロジェクト: alciakng/WormsClient
    // 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
ファイル: MoveControlScript.cs プロジェクト: DialBird/kadai
    void Start()
    {
        GameObject go = GameObject.Find("SocketIO");
        socket = go.GetComponent<SocketIOComponent>();

        //コントローラーの命令が入ってきたら処理する。(1、idを特定し、オブジェクトを特定 2、特定したオブジェクトのコンポーネントに命令)
        socket.On("move",CheckID);
    }
コード例 #12
0
ファイル: SceneController.cs プロジェクト: runyasak/Ritual-Me
    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
ファイル: ClientLogin.cs プロジェクト: EojinRho/WizardChess
	void Start () {
		DontDestroyOnLoad (gameObject);
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		socket.On ("connection", Connection);
		socket.On("loginconfirm", LoginConfirm);
	}
コード例 #15
0
ファイル: powerReceiveScript.cs プロジェクト: DialBird/kadai
    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
ファイル: LoadMap.cs プロジェクト: SuwalskiKarol/oor
	void Start () 
	{
		GameObject go = GameObject.Find("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();
		myscript = go.GetComponent<ectScript>();
		socket.Emit("LoadMap");
		socket.On("swapAllPlayer",swapAllPlayer);

	}
コード例 #18
0
ファイル: update_note.cs プロジェクト: ehackb/EHackVisual
    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
ファイル: SocketIoSetup.cs プロジェクト: dxhackers/cybermaze
    // 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
ファイル: StatusPlayer.cs プロジェクト: SuwalskiKarol/oor
	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
ファイル: newJoinScript.cs プロジェクト: DialBird/kadai
    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
ファイル: HelloSockets.cs プロジェクト: kingian/osric_sandbox
    // 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);*/

    }
コード例 #30
0
	// 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();
 }