Esempio n. 1
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------
    public void JoinZone()
    {
        // Set connection parameters
        ConfigData cfg = new ConfigData();
        cfg.Host = Host;
        #if !UNITY_WEBGL
        cfg.Port = TcpPort;
        #else
        cfg.Port = WSPort;
        #endif
        cfg.Zone = Zone;

        // Initialize SFS2X client and add listeners
        #if !UNITY_WEBGL
        sfs = new SmartFox();
        #else
        sfs = new SmartFox(UseWebSocket.WS);
        #endif
        cfg.Debug = true;

        // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);

        // Connect to SFS2X
        sfs.Connect(cfg);
    }
 //----------------------------------------------------------
 // Called when program starts
 //----------------------------------------------------------
 void Start()
 {
     smartFox = new SmartFox();
     smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection);
     smartFox.AddLogListener(LogLevel.DEBUG, OnDebugMessage);
     smartFox.Connect(ip, port);
 }
 public RoomVariableManager(SmartFox smf, Room car )
 {
     smartFox = smf;
     currentActiveRoom = smartFox.LastJoinedRoom;
     smartFox.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, conectionListChange);
     conectionsList = new List<GUIContent>();
     updateConectionsList();
     currentName = smartFox.MySelf.Name;
     SFSExtensionManager extensionManager=SFSExtensionManager.getInstance();
     extensionManager.sendRequest(new ExtensionRequest("getIP", new SFSObject()), "getIpResponse", getIPResponse);
 }
Esempio n. 4
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------

    public void OnSendButtonclicked()
    {
        Email = email.text;
        Subj  = subject.text;
        Msg   = msg.text;
        if (requredFilled())
        {
            if (Email.IndexOf("@") != -1)
            {
#if UNITY_WEBGL
                {
                    sfs        = new SmartFox(UseWebSocket.WS);
                    ServerPort = defaultWsPort;
                }
#else
                {
                    sfs        = new SmartFox();
                    ServerPort = defaultTcpPort;
                }
#endif

                sfs.ThreadSafeMode = true;
                sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
                sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
                sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
                sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
                sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

                sfs.Connect(ServerIP, ServerPort);
            }
            else
            {
                textMsg.text = "Invalid email address";
            }
        }
        else
        {
            textMsg.text = "Missing to fill required value(s)";
        }
    }//end
Esempio n. 5
0
    // get smartfox goin again
    private void Awake()
    {
        // need to look up what this even does
        Application.runInBackground = true;

        if (SmartFoxConnection.IsInitialized)
        {
            sfs = SmartFoxConnection.Connection;
        }
        else
        {
            SceneManager.LoadScene("main");
            return;
        }

        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate);
        sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);

        // spawn the player
        SpawnLocalPlayer();

        // update ui here in the future for color stuff
    }
Esempio n. 6
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------

    public void OnLoginButtonClick()
    {
        enableLoginUI(false);

        // Set connection parameters
        ConfigData cfg = new ConfigData();

        cfg.Host = Host;
                #if !UNITY_WEBGL
        cfg.Port = TcpPort;
                #else
        cfg.Port = WSPort;
                #endif
        cfg.Zone = Zone;

        // Initialize SFS2X client and add listeners
                #if !UNITY_WEBGL
        sfs = new SmartFox();
                #else
        sfs = new SmartFox(UseWebSocket.WS_BIN);
                #endif

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);

        // Connect to SFS2X
        sfs.Connect(cfg);
    }
Esempio n. 7
0
    public void RegisButtonClick()
    {
        enableLoginUI(false);

        // Set connection parameters
        Sfs2X.Util.ConfigData cfg = new ConfigData();
        cfg.Host    = Host;
        cfg.Port    = TcpPort;
        cfg.Zone    = Zone;
        cfg.UdpHost = Host;
        cfg.UdpPort = UdpPort;

        // Initialize SFS2X client and add listeners
        sfs = new SmartFox();

        // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        // Connect to SFS2X
        sfs.Connect(cfg);
    }
Esempio n. 8
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------

    public void OnLoginButtonClick()
    {
        enableLoginUI(false);

        // Set connection parameters
        ConfigData cfg = new ConfigData();

        cfg.Host = Host;
                #if !UNITY_WEBGL
        cfg.Port = TcpPort;
                #else
        cfg.Port = WSPort;
                #endif
        cfg.Zone = zoneInput.text;

        // Initialize SFS2X client and add listeners
                #if !UNITY_WEBGL
        sfs = new SmartFox();
                #else
        sfs = new SmartFox(UseWebSocket.WS_BIN);
                #endif

        Debug.Log("SFS2X C# API v" + sfs.Version);

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
        sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
        sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd);

        // Connect to SFS2X
        sfs.Connect(cfg);
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        if (SmartFoxConnection.CheckConnection())
        {
            ChooseDice = 6;
            Debug.Log("CheckConnection");
            sfs = SmartFoxConnection.Connection;
            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
            sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariablesUpdate);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
            sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);

            reset = false;
            Score = 100;
            cv.SetActive(false);
            UserName.text = "User Name: " + Connection.username;
        }
        else
        {
            SceneManager.LoadScene("Login");
        }
    }
Esempio n. 10
0
 // Use this for initialization
 void Start()
 {
     smartFox = SmartFoxConnection.Connection;
     smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
     if (smartFox == null) {
         Application.LoadLevel("The Lobby");
         return;
     }
     string nombre = "salaP";
     ISFSObject obj = new SFSObject ();
     obj.PutUtfString ("nombre", nombre);
     ExtensionRequest request = new ExtensionRequest("crearSalaVS", obj); // True flag = UDP
     smartFox.Send (request);
 }
Esempio n. 11
0
    public void OnTourButtonClicked()
    {
                        #if UNITY_WEBGL
        {
            sfs        = new SmartFox(UseWebSocket.WS);
            ServerPort = defaultWsPort;
        }
                        #else
        {
            sfs        = new SmartFox();
            ServerPort = defaultTcpPort;
        }
                        #endif

        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit);
        sfs.Connect(ServerIP, ServerPort);
    }    //end
Esempio n. 12
0
 private void SubscribeEvents()
 {
     sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
     sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
     sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
     sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
     sfs.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit);
     sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
 }
Esempio n. 13
0
    void Start()
    {
        SERVER = new SmartFox();

        //Event listener for the connection
        SERVER.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        SERVER.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);

        //Event listener for the login data
        SERVER.AddEventListener(SFSEvent.LOGIN, OnLogin);
        SERVER.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);

        //
        SERVER.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, Variable_Update);

        //Server details
        ConfigData config = new ConfigData();

        config.Host  = IP;
        config.Port  = TCP;
        config.Zone  = "BasicExamples";
        config.Debug = true;

        //Attempt connection
        SERVER.Connect(config);

        rooms = SERVER.RoomManager.GetRoomList();


        if (rooms.Count == 0)
        {
            MMORoom room = new MMORoom(0, "johnnny");
            rooms.Add(room);
            print(room.Name);
        }
    }
Esempio n. 14
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------

    public void OnResetPasswordButtonClicked()
    {                                          //on reset password button clicked, login to server zone and reset password
        username = UserName.text;
        if (username == "" || username == " ") //to check the value
        {
            TextMessage.text = "Missing to fill required value";
        }
        else
        {                           // Enable interface
            enableInterface(false); //methods to disable typing in input field

          #if UNITY_WEBGL           //type of build "WebGl"
            {
                sfs        = new SmartFox(UseWebSocket.WS);
                ServerPort = defaultWsPort;
            }
            #else//type of build "web player"
            {
                sfs        = new SmartFox();
                ServerPort = defaultTcpPort;
            }
              #endif

            sfs.ThreadSafeMode = true;//create tread to the user
            // Event Listeners
            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
            sfs.Connect(ServerIP, ServerPort); //connecting
            enableInterface(true);             //methods to enable typing in input field
            UserName.text    = "";
            TextMessage.text = "";
        }
    }
Esempio n. 15
0
    /**
     * Initialize the game.
     */
    public void InitGame(SmartFox smartFox)
    {
        // Register to SmartFox events
        sfs = smartFox;
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
        timer = new MyTimer();
        // Setup my properties
        myPlayerID = sfs.MySelf.PlayerId;

        // Reset game board
        ResetGameBoard();

        // Tell extension I'm ready to play
        sfs.Send(new ExtensionRequest("ready", new SFSObject(), sfs.LastJoinedRoom));
    }
    /**
     * Initialize the game.
     */
    public void InitGame(SmartFox smartFox)
    {
        // Register to SmartFox events
        sfs = smartFox;
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        // Setup my properties
        myPlayerID = sfs.MySelf.PlayerId;

        // Reset game board
        ResetGameBoard();

        // Tell extension I'm ready to play
        sfs.Send(new ExtensionRequest("ready", new SFSObject(), sfs.LastJoinedRoom));
    }
Esempio n. 17
0
    void SetupListeners()
    {
        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);

        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
    }
Esempio n. 18
0
    public static void Connect(string uname)
    {
        if (sfs == null || !sfs.IsConnected)
        {
            username = uname;
            // CONNECT

            Debug.Log("Now connecting...");

            // Add listeners
            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

            sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
            sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);
            sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);

            //sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
            sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            //sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
            sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
            //sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd);

            // Set connection parameters
            ConfigData cfg = new ConfigData();
            cfg.Host = defaultHost;
            cfg.Port = Convert.ToInt32(defaultTcpPort.ToString());
            cfg.Zone = zone;
            //cfg.Debug = true;

            // Connect to SFS2X
            sfs.Connect(cfg);
        }
        else
        {
            // Disconnect from SFS2X
            sfs.Disconnect();
            trace("Disconnected");
        }
    }
    // Use this for initialization
    void Start()
    {
        me = this;
        if (!Statici.multigiocatoreOn)
            return;

        Application.runInBackground = true;
        if (!SmartFoxConnection.NonNulla)
        {
            SceneManager.LoadScene("ScenaZero");
            return;
        }

        sfs = SmartFoxConnection.Connection;
        sfs.ThreadSafeMode = true;
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
    }
Esempio n. 20
0
    void Start()
    {
        sfs = new SmartFox();
        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
        sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectRequest);
    }
Esempio n. 21
0
    protected void Awake()
    {
        handlers = new Dictionary <string, IMessageHandler>();
        Application.runInBackground = true;

        if (SmartFoxConnection.IsInitialized)
        {
            smartFox = SmartFoxConnection.Connection;
        }
        else
        {
            smartFox = new SmartFox(debug);
        }

        // Create encryption provider
        provider = EncryptionProvider.GetInstance();
        smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
    }
Esempio n. 22
0
    // Use this for initialization
    void Start()
    {
        sfs = new SmartFox();
        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, OnConfigLoad);
        sfs.AddEventListener(SFSEvent.CONFIG_LOAD_FAILURE, OnConfigFail);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
        sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        if (UseConfigFile)
        {
            sfs.LoadConfig(Application.dataPath + "/" + ConfigFile);
        }
        else
        {
            sfs.Connect(ServerIP, ServerPort);
        }
    }
Esempio n. 23
0
    // Start is called before the first frame update
    void Start()
    {
        gameManager        = GameObject.Find("Board").GetComponent <GameManager>();
        board              = GameObject.Find("Board").GetComponent <Board>();
        sfs                = new SmartFox();
        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginR);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
    }
Esempio n. 24
0
	// Use this for initialization
	void Awake() {
		
		Application.runInBackground = true; // so unity doesn't timeout when switching focus
		
		// initialize smartfox with debug flag
		smartFox = new SmartFox(debug);
		
		// Register callback delegate
		smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection);
		smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
		smartFox.AddEventListener(SFSEvent.LOGIN, OnLogin);
		smartFox.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit);
		smartFox.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
		smartFox.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
		smartFox.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdded);

		smartFox.AddLogListener(LogLevel.DEBUG, OnDebugMessage);

		smartFox.Connect(serverName, serverPort);
	}
Esempio n. 25
0
    void Start()
    {
        sfs = gm.startSmartFox();

        if (sfs.IsConnected)
        {
            sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, userEnterRoomHandler);
            sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, userExitRoomHandler);
            sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, userVarUpdateHandler);
            sfs.AddEventListener(SFSEvent.PROXIMITY_LIST_UPDATE, proximityListUpdateHandler);
            sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, publicMessageHandler);
            sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, messageHandler);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, lostConnectionHandler);
        }

        if (gm.localPlayer == null)
        {
            gm.SpawnLocalPlayer();
        }
    }
Esempio n. 26
0
        public void Connect()
        {
            if (!inGuild || isConnecting)
            {
                return;
            }

            Disconnect();
            isConnecting = true;

            sfs = new SmartFox();
            sfs.ThreadSafeMode = true;
            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoined);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
            sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            sfs.Connect(cfg);
            D.Log(LoggingTags.Chat, "SFS reconnecting...");
        }
Esempio n. 27
0
    public void OnLoginButtonClicked()
    {
        username = UserName.text;
        password = Password.text;

        if (username == "" || username == " " || password == "" || password == " ")
        {
            TextMessage.text = "Missing to fill required value";
        }
        else
        {          // Enable interface
            enableInterface(false);

                        #if UNITY_WEBGL
            {
                sfs        = new SmartFox(UseWebSocket.WS);
                ServerPort = defaultWsPort;
            }
                        #else
            {
                sfs        = new SmartFox();
                ServerPort = defaultTcpPort;
            }
                        #endif

            sfs.ThreadSafeMode = true;

            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.UDP_INIT, OnUdpInit);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
            sfs.Connect(ServerIP, ServerPort);
        }
    }    //end
Esempio n. 28
0
    /// <summary>
    /// 初始化默认游戏区
    /// </summary>
    /// <param name="defaultZone"></param>
    public void Init(string Zone)
    {
        this.defaultZoneName = Zone;
        sfs.ThreadSafeMode   = true;
        //是否开启调试模式
        //sfs.Debug = true;

        //监听客户端事件
        sfs.AddEventListener(SFSEvent.CONNECTION, OnSFSEventHandler);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnSFSEventHandler);

        //监听客户端登录事件
        sfs.AddEventListener(SFSEvent.LOGIN, OnSFSEventHandler);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnSFSEventHandler);

        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionHandler);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnSFSEventHandler);

        Global.Log("【NetManager】初始化成功!");
    }
        public override void _Ready()
        {
            var x = new Node2D();

            _sfs.ThreadSafeMode = false;
            _sfs.Debug          = true;

            _sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            _sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            _sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
            _sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
            _sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout);

            var cfg = new ConfigData
            {
                Host = _config.Host,
                Port = _config.Port,
                Zone = _config.ZoneName
            };

            _sfs.Connect(cfg);
        }
 public void OnLoginButtonClick()
 {
     if (!loggedIn)
     {
         sfs = new SmartFox();
         sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
         sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
         sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
         sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
         sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout);
         sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
         ConfigData cfg = new ConfigData();
         cfg.Host = "127.0.0.1";
         cfg.Port = 9933;
         cfg.Zone = zone;
         sfs.Connect(cfg);
     }
     else
     {
         sfs.Send(new LogoutRequest());
     }
 }
Esempio n. 31
0
    public void BottoneLogin()
    {
        ManagerScenaZero.AttivaDisattivaCanvasGroupLogin(false);
        erroreText.text = "";

        ConfigData cfg = new ConfigData();
        cfg.Host = host;
        cfg.Port = port;
        cfg.Zone = zona;

        sfs = new SmartFox();

        sfs.ThreadSafeMode = true;
        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);

        sfs.Connect(cfg);
    }
Esempio n. 32
0
    public void onConnectClicked()
    {
        EnableConnect(false);
        // Set connection parameters
        ConfigData cfg = new ConfigData();

        cfg.Host           = Host;
        cfg.Port           = TcpPort;
        cfg.Zone           = Zone;
        cfg.UseBlueBox     = false;
        sfs                = new SmartFox();
        sfs.ThreadSafeMode = true;

        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);

        // Connect to SFS2X
        sfs.Connect(cfg);
    }
Esempio n. 33
0
 private void SubscribeEvent()
 {
     sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
 }
Esempio n. 34
0
    public SmartFoxConnector()
    {
        Debug.Log("SmartFoxInterface init");
        _smartFox = new SmartFox();
        _smartFox.Debug = true;

        _smartFox.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        _smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        _smartFox.AddEventListener(SFSEvent.LOGIN, OnLogin);
        _smartFox.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        _smartFox.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, OnRoomVariableUpdate);
        _smartFox.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        _smartFox.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
        _smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        _smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        _smartFox.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd);
        _smartFox.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomAddError);
        _smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
    }
Esempio n. 35
0
    void Start()
    {
        backlog = (NextStories)GameObject.Find("ButtonNextUS/Center").GetComponent("NextStories");
        poker = (crearPlanningPoker)(GameObject.Find("panelPlanningPoker")).GetComponent("crearPlanningPoker");
        listaSprints = new ArrayList();
        listaUsers = new ArrayList();
        listaDailyMeetings=new ArrayList();//agregamos esto

        /*UserVS u1 = new UserVS("marcelo","scrummaster");
        UserVS u2 = new UserVS("nico","scrummember");
        UserVS u3 = new UserVS("maria","scrummember");
        UserVS u4 = new UserVS("juan","scrummember");
        listaUsers.Add(u1);
        listaUsers.Add(u2);
        listaUsers.Add(u3);
        listaUsers.Add(u4);*/

        if (!SmartFoxConnection.IsInitialized) {
            Debug.Log("Smartfox is not initialized");
            Application.LoadLevel("The Lobby");
            return;
        }
        smartFox = SmartFoxConnection.Connection;

        // Register callback delegates
        //smartFox.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
        //smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        //smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        //smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        //smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserLeaveRoom);
        //smartFox.AddLogListener(logLevel, OnDebugMessage);
        //	smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        //	smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        //	smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        //	smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserLeaveRoom);

        smartFox.AddEventListener (SFSEvent.EXTENSION_RESPONSE, OnExtensionResponce);

        param = new SFSObject();
        param.PutLong("id_proyecto",user.getProyecto());

        //smartFox.Send(new ExtensionRequest("cargarDatos", param));

        smartFox.Send(new ExtensionRequest("cargarDatos",param));
        Debug.Log("cargarDatos");
        //smartFox.Send (new ExtensionRequest("crearus",new SFSObject()));

        //Debug.Log ("mando datos");
    }
	//----------------------------------------------------------
	// Public interface methods for UI
	//----------------------------------------------------------

	public void doConnectToServer() {
		if (sfs == null || !sfs.IsConnected) {
			
			// Initialize SFS2X client and add listeners
			// WebGL build uses a different constructor
			#if !UNITY_WEBGL
				sfs = new SmartFox();
				label = "Connecting via Standard Sockets";
			#else
				sfs = new SmartFox(UseWebSocket.WS);
				label = "Connecting via Websocket";
			#endif
			 
			// Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
			sfs.ThreadSafeMode = true;
			
			sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
			sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
			sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnCryptoInit);
			sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
			sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
			sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
			sfs.AddEventListener(SFSEvent.ROOM_JOIN,OnRoomJoined);
			sfs.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE,onRoomVariableUpdate);
			sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE,onUserVariablesUpdate);
		/*	sfs.AddLogListener(LogLevel.DEBUG, OnDebugMessage);
			sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
			sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);*/
			sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);
			// Set connection parameters
			ConfigData cfg = new ConfigData();
			
			
			#if !UNITY_WEBGL
				cfg.Host = "64.91.226.4";
				cfg.Port = 9933;
			#endif
			#if UNITY_WEBGL
				cfg.Port = 8888;
				cfg.Host = "64.91.226.4";
			#endif
			cfg.Zone = "HA3D";
			cfg.Debug = false;
			
			// Connect to SFS2X

			// Debug.Log("Client Version: "+sfs.Version);
			sfs.Connect(cfg);
		} else {
			
			// DISCONNECT
			
			// Disable button
			
			// Disconnect from SFS2X
			sfs.Disconnect();
		}
	}
Esempio n. 37
0
    public void Init()
    {
        SFInstance = new SmartFox();
        SFInstance.ThreadSafeMode = true;

        SFInstance.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        SFInstance.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);

        SFInstance.AddEventListener(SFSEvent.LOGIN, OnLoginToSF);
        SFInstance.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginToSFError);

        SFInstance.AddEventListener(SFSEvent.ROOM_JOIN, OnSFRoomJoin);
        SFInstance.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnSFRoomJoinError);
        SFInstance.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnSFRoomLeave);

        SFInstance.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnSFExtensionResponse);

        SFInstance.AddLogListener(LogLevel.INFO, OnLogMessageInfo);
        SFInstance.AddLogListener(LogLevel.WARN, OnLogMessageWarn);
        SFInstance.AddLogListener(LogLevel.ERROR, OnLogMessageError);

        DoConnect();
    }
Esempio n. 38
0
 private void EventListener()
 {
     sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionReponse);
 }
    // Use this for initialization
    void Start()
    {
        LoginPanel = GameObject.Find("LoginBox");
        RegisterPanel = GameObject.Find("RegisterBox");
        RegisterPanel.SetActive(false);
        MessageText = GameObject.Find("MessageText");
        MessageText.SetActive(false);

        UsernameTB = GameObject.Find("UsernameTB").GetComponent<InputField>();
        PasswordTB = GameObject.Find("PasswordTB").GetComponent<InputField>();
        UsernameTB.Select();

        SFServer = new SmartFox();

        //Set our basic default connection parameters
        this.OurConfigData.Host = "biele.us";
        this.OurConfigData.Port = 9933;
        this.OurConfigData.Zone = GAME_ZONE;

        // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
        SFServer.ThreadSafeMode = true;

        SFServer.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        SFServer.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        SFServer.AddEventListener(SFSEvent.LOGIN, OnLogin);
        SFServer.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        SFServer.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        SFServer.Connect(this.OurConfigData);
    }
    // Use this for initialization
    void Start()
    {
        if(SmartFoxConnection.Connection == null)
        {
            SceneManager.LoadScene("Login");
            return;
        }
        SFServer = SmartFoxConnection.Connection;
        SmartFoxConnection.NeedsDespawn = true;

        // Register callback delegates
        SFServer.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        SFServer.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        //Register ServerResponseHandlers
        ourSRHDictionary.Add("SpawnPlayer", new SpawnPlayerHandler());
        ourSRHDictionary.Add("DespawnPlayer", new DespawnPlayerHandler());
        ourSRHDictionary.Add("PositionUpdate", new PositionUpdateHandler());
        ourSRHDictionary.Add("RotationUpdate", new RotationUpdateHandler());
        ourSRHDictionary.Add("SpawnNPC", new SpawnNPCHandler());
        ourSRHDictionary.Add("SpawnResource", new SpawnResourceHandler());
        ourSRHDictionary.Add("ProcessChat", new ProcessChatHandler());
        ourSRHDictionary.Add("GatherResource", new GatherResourceHandler());
        ourSRHDictionary.Add("SpawnSettlement", new SpawnSettlementHandler());
        ourSRHDictionary.Add("SpawnNode", new SpawnNodeHandler());
        ourSRHDictionary.Add("CenterNodeInformation", new CenterNodeInformationHandler());
        ourSRHDictionary.Add("InventoryUpdate", new InventoryUpdateHandler());

        ISFSObject ObjectIn = new SFSObject();
        ObjectIn.PutUtfString("AccountName", SFServer.MySelf.Name.ToLower());
        Debug.Log("Spawning player");
        SFServer.Send(new ExtensionRequest("SpawnPlayer", ObjectIn));
    }
Esempio n. 41
0
    private void Start()
    {
        // Create the instance to the smarfox object
        _sfs = new SmartFox(true);

        _sfs.AddLogListener(logLevel, OnDebugMessage);

        _sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        _sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);

        _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        _sfs.AddEventListener(SFSEvent.LOGOUT, OnLogout);

        OnStart();

        // Connect to the server. It need to be running first !
        _sfs.Connect(serverIP, serverPort);
    }
Esempio n. 42
0
 void Start()
 {
     firstUpdate = true;
     distanceDelta = Vector3.zero;
     smartFox = SmartFoxConnection.Connection;
     smartFox.AddEventListener(SFSEvent.OBJECT_MESSAGE, onMessage);
 }
Esempio n. 43
0
    // Update is called once per frame
    void Update()
    {
        if (StartConnection) {
            sfs = new SmartFox ();
            sfs.ThreadSafeMode = true;

            sfs.AddEventListener (SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener (SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener (SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener (SFSEvent.ROOM_JOIN, OnJoinRoom);
            sfs.AddEventListener (SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
            sfs.AddEventListener (SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            sfs.AddEventListener (SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
            sfs.AddEventListener (SFSEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate);

            sfs.Connect (ServerIP, ServerPort);
            StartConnection = false;
            ConnectionRunning = true;
        }

        if(ConnectionRunning)
            sfs.ProcessEvents ();
    }
Esempio n. 44
0
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // Private methods
    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

    /**
     * Connects to SFS2X.
     */
    void DoConnect()
    {
        // Always create a new instance of the SmartFox class
                #if !UNITY_WEBGL
        sfs = new SmartFox();
                #else
        sfs = new SmartFox(UseWebSocket.WS_BIN);
                #endif

        // Add SFS2X event listeners
        sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
        sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
        sfs.AddEventListener(SFSEvent.PING_PONG, OnPingPong);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
        sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVarsUpdate);
        sfs.AddEventListener(SFSEvent.PROXIMITY_LIST_UPDATE, OnProximityListUpdate);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        errorMsg        = "";
        usernameEnabled = false;

        // Set connection parameters
        ConfigData cfg = new ConfigData();
        cfg.Host = Host;
                #if !UNITY_WEBGL
        cfg.Port = TcpPort;
                #else
        cfg.Port = WSPort;
                #endif
        cfg.Zone = "SpaceWar";

        // Connect
        sfs.Connect(cfg);

        Game.Rotate += this.Rotate;
        Game.Thrust += this.Thrust;
        Game.Fire   += this.Fire;
    }
Esempio n. 45
0
    void Start()
    {
        if (!SmartFoxConnection.IsInitialized) {
            Application.LoadLevel("Connection");
            return;
        }
        smartFox = SmartFoxConnection.Connection;
        smartFox.AddEventListener (SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        Debug.Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> add event listener");
        SFSObject param = new SFSObject();
        RoomVariable rv = smartFox.LastJoinedRoom.GetVariable("idGrupo");
        long grupo;
        grupo = (long)rv.GetIntValue();
        param.PutUtfString("nick",getMyUserName());
        param.PutLong("grupo",grupo);

        smartFox.Send(new ExtensionRequest("cargarDatosJugador",param));
        SFSObject param2 = new SFSObject();
        Debug.Log ( " proyecto");
        param2.PutLong ("Id_Proyecto", this.getProyecto ());
        Debug.Log (this.getProyecto () + " proyecto ");
        smartFox.Send(new ExtensionRequest("obtenerPathProyecto",param2));
        Debug.Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> smartfox send");

        link = (MultiPlayer)GameObject.Find("Multi").GetComponent("MultiPlayer");

        Debug.Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> UserVS start termino");
    }
Esempio n. 46
0
    // Use this for initialization
    private void Start()
    {
        if (!Statici.multigiocatoreOn)
            return;
        TimeManager.Instance.Init();
        Application.runInBackground = true;
        punteggi.text = "";
        punteggi.gameObject.SetActive(false);

        gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
        gestoreCanvasNetwork = GameObject.Find("ManagerCanvasMultiplayer").GetComponent<GestoreCanvasNetwork>();
        me = this;
        minimappa = GameObject.Find("Minimappa").GetComponent<Minimappa>();
        if (!SmartFoxConnection.NonNulla)
        {
            SceneManager.LoadScene("ScenaZero");
            return;
        }
        sfs = SmartFoxConnection.Connection;
        sfs.ThreadSafeMode = true;
        sfs.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
        sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);

        SpawnaPlayerLocale();
    }
Esempio n. 47
0
    // Use this for initialization
    private void Start()
    {
        Statici.inGioco = false;
        canvasGroupChat.interactable = true;
        canvasGroup.interactable = true;
        Statici.datiPersonaggio = new Serializzabile<ValoriPersonaggioS>(Statici.NomeFilePersonaggio);
        Statici.finePartita = false;
        sliderUserMax.minValue = 2;
        sliderUserMax.maxValue = numeroMassimoUtentiInStanza;
        contenutoPartiteCanvasGroup = ContenutoListaPartite.GetComponent<CanvasGroup>();
        BloccaSbloccaCanvas(true);
        buttonReady.gameObject.SetActive(false);
        ResettaErrore();
        if (!SmartFoxConnection.NonNulla)
        {
            SceneManager.LoadScene("ScenaZero");
            return;
        }
        sfs = SmartFoxConnection.Connection;
        sfs.ThreadSafeMode = true;
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
        sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
        sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdded);
        sfs.AddEventListener(SFSEvent.ROOM_CREATION_ERROR, OnRoomCreationError);
        sfs.AddEventListener(SFSEvent.ROOM_REMOVE, OnRoomRemoved);
        sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
        sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        sfs.AddEventListener(SFSEvent.USER_COUNT_CHANGE, OnUserCountChange);
        sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
        sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);

         Statici.playerLocaleGO = Instantiate(Resources.Load(Statici.datiPersonaggio.Dati.nomeModello), startPoint.position, Quaternion.identity) as GameObject;
        //aggiunto by LUCA
        NetworkPlayer netPlayer=Statici.playerLocaleGO.AddComponent<NetworkPlayer>();
        netPlayer.playerLocale = true;
        //
        Statici.aggiungiComponenteAnimazione(Statici.playerLocaleGO,true);  //AGGIUNTO componente animazione

        Statici.playerLocaleGO.GetComponentInChildren<TextMesh>().text = Statici.nomePersonaggio;

        PopolaListaPartite();
    }
Esempio n. 48
0
    public void Connect()
    {
        if (sfs == null || !sfs.IsConnected)
        {
            // CONNECT

                #if UNITY_WEBPLAYER
            // Socket policy prefetch can be done if the client-server communication is not encrypted only (read link provided in the note above)
            if (!Security.PrefetchSocketPolicy(hostInput.text, Convert.ToInt32(portInput.text), 500))
            {
                Debug.LogError("Security Exception. Policy file loading failed!");
            }
                #endif

            Debug.Log("Now connecting...");

            // Initialize SFS2X client and add listeners
            // WebGL build uses a different constructor
                #if !UNITY_WEBGL
            sfs = new SmartFox();
                #else
            sfs = new SmartFox(UseWebSocket.WS_BIN);
                #endif

            // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
            sfs.ThreadSafeMode = true;

            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);

            sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
            sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);
            sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);

            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnRoomJoinError);
            sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            sfs.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);
            sfs.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
            sfs.AddEventListener(SFSEvent.ROOM_ADD, OnRoomAdd);

            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);



            // Set connection parameters
            ConfigData cfg = new ConfigData();
            cfg.Host  = IpAddress;
            cfg.Port  = Convert.ToInt32(Port);
            cfg.Zone  = "slotZ";
            cfg.Debug = DebugMode;

            // Connect to SFS2X
            sfs.Connect(cfg);
        }
    }
Esempio n. 49
0
 // Use this for initialization
 void Start()
 {
     _sfs = new SmartFox();
     _sfs.ThreadSafeMode = true;
     _sfs.AddEventListener(SFSEvent.CONNECTION , OnConnection);
     _sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
     _sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
     _sfs.AddEventListener(SFSEvent.CONFIG_LOAD_SUCCESS, OnConfigLoad);
     _sfs.AddEventListener(SFSEvent.CONFIG_LOAD_FAILURE, OnConfigFail);
     _sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
     _sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
     _sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
     _sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnSumResponse);
     Security.PrefetchSocketPolicy(serverIp,serverPort);
     if(useConfigFile)
         _sfs.LoadConfig(Application.dataPath + "/" + configFile);
     else
         _sfs.Connect(serverIp,serverPort);
 }
Esempio n. 50
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------


    public void OnCreateAccountButtonClicked()
    {       //on create button clicked, all values are stored in variables then login to server
        int usernameSpace, firstnameSpace, lastnameSpace;

        username       = UserName.text;    //to store username
        usernameSpace  = username.IndexOf(" ");
        password       = Password.text;    //to store password
        Conpassword    = ConPassword.text; //to store confirm password
        email          = Email.text;       ///tpstore email
        biography      = Biography.text;   //to store bio
        firstname      = FirstName.text;   //to storefirst name
        firstnameSpace = firstname.IndexOf(" ");
        lastname       = LastName.text;    //to store last name
        lastnameSpace  = lastname.IndexOf(" ");
        bool ARoom = ActivateRoom.isOn;    //to store activate room

        if (ARoom == true)
        {
            Act_Room = "Y";
        }
        else
        {
            Act_Room = "N";
        }

        bool Account = AccountType.isOn;        //to store account type (public, private)

        if (Account == true)
        {
            Account_T = "private";
        }
        else
        {
            Account_T = "public";
        }

        bool avatar = MAvatar.isOn;//to store avatar gender

        if (avatar == true)
        {
            Avt = "M";
        }
        else
        {
            Avt = "F";
        }

        int    AdminIndex = username.IndexOf("n");
        string admin      = username.Substring(0, AdminIndex + 1);

        if (requredFilled())                                                        //method to check that all required values filled
        {
            if (usernameSpace == -1 && firstnameSpace == -1 && lastnameSpace == -1) //to prevent spaces in names
            {
                if (!admin.Equals("Admin"))                                         //to prevent the name start with "Admin"
                {
                    if (password == Conpassword)                                    //to check password and it's confirm are matching
                    {
                        if (email.IndexOf("@") != -1)                               //to validate email
                        {                                                           // Enable interface
                            enableInterface(false);                                 //method to disable typying in input field while proccesing
                            ///connect with server
                                                        #if UNITY_WEBGL             //type of building "WEBGL"
                            {
                                sfs        = new SmartFox(UseWebSocket.WS);
                                ServerPort = defaultWsPort;
                            }
                                                        #else //type of building "Web player"
                            {
                                sfs        = new SmartFox();
                                ServerPort = defaultTcpPort;
                            }
                            #endif
                            sfs.ThreadSafeMode = true; //create threds
                                                       //events listeners
                            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
                            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
                            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
                            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
                            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
                            sfs.Connect(ServerIP, ServerPort);

                            enableInterface(true);                            //method to enable typying in input field while proccesing
                            UserName.text    = "";
                            Password.text    = "";
                            ConPassword.text = "";
                            Email.text       = "";
                            FirstName.text   = "";
                            LastName.text    = "";
                        }
                        else //error messages "invalid email"
                        {
                            TextMessage.text = "Invalid email account";
                        }
                    }
                    else                     //error messages "password not equal to it's confirm"
                    {
                        TextMessage.text = "The password and its confirm are not matching";
                    }
                }
                else                 //error messages "username not start with admin"
                {
                    TextMessage.text = "The username should not start with \"Admin\" string";
                }
            }
            else            //error messages "names must not contains spaces"
            {
                TextMessage.text = "Username,firstname & lastname should not contains a space";
            }
        }
        else        //error messages "missing values"
        {
            TextMessage.text = "Missing to fill required value";
        }
    }//end create account
    // Use this for initialization
    void Start()
    {
        //Identify UI Elements
        this.CharacterPanel = new List<GameObject>();
        this.CharacterListPanel = GameObject.Find("CharacterListPanel");

        if(SmartFoxConnection.Connection == null)
        {
            SceneManager.LoadScene("Login");
            return;
        }
        SFServer = SmartFoxConnection.Connection;

        // Register callback delegates
        SFServer.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        SFServer.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);

        //Send AccountName to get back list of Account's Characters
        ISFSObject ObjectIn = new SFSObject();
        ObjectIn.PutUtfString("AccountName", SFServer.MySelf.Name.ToLower());
        SFServer.Send(new ExtensionRequest("CharacterList", ObjectIn));
    }
Esempio n. 52
0
    void Start()
    {
        //reemplazar el seteo por la funcion que se deba aplicar para saber el estado

        this.oauth1ServiceConnector= new OauthServiceConnector(SocialNetworkConfig.getConfig(ConfigurationConstants.SERVER_URL_OAUTH1));
        this.oauth2ServiceConnector= new OauthServiceConnector(SocialNetworkConfig.getConfig(ConfigurationConstants.SERVER_URL_OAUTH2));

        chatScrollPosition = Vector2.zero;
        //bool debug = false;
        if (SmartFoxConnection.IsInitialized)
        {
            smartFox = SmartFoxConnection.Connection;
            smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
        }
    }
Esempio n. 53
0
 void Start()
 {
     if (!SmartFoxConnection.IsInitialized) {
                     Application.LoadLevel ("Connector");
                     return;
             }
             server = SmartFoxConnection.Connection;
             server.AddEventListener (SFSEvent.CONNECTION_LOST, OnConnectionLost);
             server.AddEventListener (SFSEvent.PROXIMITY_LIST_UPDATE, OnProximityListUpdate);
             server.AddEventListener (SFSEvent.MMOITEM_VARIABLES_UPDATE, OnItemUpdate);
             server.AddEventListener (SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
             server.AddEventListener (SFSEvent.ROOM_JOIN, OnRoomJoin);
             Debug.Log ("Joining room..");
             server.Send (new JoinRoomRequest (room));
             camera = GetComponent<GameCamera> ();
 }
Esempio n. 54
0
    void Start()
    {
        sfs = Connection.Instance().Sfs();

        sfs.AddEventListener(SFSEvent.PROXIMITY_LIST_UPDATE, OnProximityListUpdate);
        sfs.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariablesUpdate);
        sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);

        float x = (float)sfs.MySelf.GetVariable("x").GetDoubleValue();
        float y = (float)sfs.MySelf.GetVariable("y").GetDoubleValue();
        float z = (float)sfs.MySelf.GetVariable("z").GetDoubleValue();

        GameObject playerGo = Instantiate(playerPrefab, new Vector3(x, y, z), Quaternion.identity) as GameObject;
        sfs.MySelf.Properties.Add("GameObject", playerGo);
        users.Add(sfs.MySelf.Id, sfs.MySelf);
    }
Esempio n. 55
0
    //----------------------------------------------------------
    // Unity callbacks
    //----------------------------------------------------------
    void Start()
    {
        if (!SmartFoxConnection.IsInitialized) {
            Application.LoadLevel("Connection");
            return;
        }
        smartFox = SmartFoxConnection.Connection;

        // Register callback delegates
        smartFox.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
        smartFox.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
        smartFox.AddEventListener(SFSEvent.USER_VARIABLES_UPDATE, OnUserVariableUpdate);
        smartFox.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
        smartFox.AddEventListener(SFSEvent.USER_ENTER_ROOM, OnUserEnterRoom);

        smartFox.AddLogListener(logLevel, OnDebugMessage);

        // Start this clients avatar and get cracking!
        int numModel = UnityEngine.Random.Range(0, playerModels.Length);
        int numMaterial = UnityEngine.Random.Range(0, playerMaterials.Length);
        SpawnLocalPlayer(numModel, numMaterial);
    }
Esempio n. 56
0
    // Use this for initialization
    void Start()
    {
        //GameObject.Find("Player").AddComponent("AnimationController");

        if (!SmartFoxConnection.IsInitialized) {
            Application.LoadLevel("Connection");
            return;
        }
        else{
            smartFox = SmartFoxConnection.Connection;
            smartFox.AddEventListener(SFSEvent.OBJECT_MESSAGE, OnObjectMessage);
            smartFox.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnUserUpdate);
            smartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE,onr);

        }

        ISFSObject obj=new  SFSObject();
        obj.PutUtfString("name",ConnectionGUI.username);
        GameObject.Find ("PlayerCustom").name = ConnectionGUI.username;
        //sfs.Send(new JoinRoomRequest(room));
        smartFox.Send(new ExtensionRequest("SomeNumberHandle",obj));
    }
    void Start()
    {
                #if !UNITY_WEBGL
                        port = defaultTcpPort.ToString();
                #else
		                        port = defaultWsPort.ToString();
                #endif

                        if (sfs == null || !sfs.IsConnected)
                        {

                            // CONNECT

                #if UNITY_WEBPLAYER
			                // Socket policy prefetch can be done if the client-server communication is not encrypted only (read link provided in the note above)
			                if (!Security.PrefetchSocketPolicy(defaultHost, Convert.ToInt32(port), 500)) {
				                Debug.LogError("Security Exception. Policy file loading failed!");
			                }
                #endif

                            // Enable interface


                            // Initialize SFS2X client and add listeners
                            // WebGL build uses a different constructor
                #if !UNITY_WEBGL
                            sfs = new SmartFox();
                #else
			                sfs = new SmartFox(UseWebSocket.WS);
                #endif

            // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
            sfs.ThreadSafeMode = true;

            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);

            sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
            sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);
            sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);

        }
        else
        {

            sfs.Disconnect();
        }
    }
Esempio n. 58
0
 void Start()
 {
     SetMessage ("Loading..");
             server = new SmartFox (true);
             server.AddEventListener (SFSEvent.CONNECTION, OnConnection);
             server.AddEventListener (SFSEvent.CONNECTION_LOST, OnConnectionLost);
             server.AddEventListener (SFSEvent.LOGIN, OnLogin);
             server.AddEventListener (SFSEvent.LOGIN_ERROR, OnLoginError);
             SetMessage ("Connecting..");
             if (Security.PrefetchSocketPolicy (serverName, serverPort, 200)) {
                     server.Connect (serverName, serverPort);
             } else {
                     SetError ("Failed to prefetch the webplayer socket security policy.");
             }
 }
Esempio n. 59
0
    //----------------------------------------------------------
    // Public interface methods for UI
    //----------------------------------------------------------

    public void OnButtonClick()
    {
        if (sfs == null || !sfs.IsConnected)
        {
            // CONNECT

                        #if UNITY_WEBPLAYER
            if (!useEncryption)
            {
                // Socket policy prefetch can be done if the client-server communication is not encrypted only (read link provided in the note above)
                if (!Security.PrefetchSocketPolicy(hostInput.text, Convert.ToInt32(portInput.text), 500))
                {
                    Debug.LogError("Security Exception. Policy file loading failed!");
                }
            }
                        #endif

            // Enable interface
            enableInterface(false);

            // Clear console
            debugText.text = "";
            debugScrollRect.verticalNormalizedPosition = 1;

            trace("Now connecting...");

            // Initialize SFS2X client and add listeners
            // WebGL build uses a different constructor
                        #if !UNITY_WEBGL
            sfs = new SmartFox();
                        #else
            sfs = new SmartFox(useEncryption ? UseWebSocket.WSS_BIN : UseWebSocket.WS_BIN);
                        #endif

            // Set ThreadSafeMode explicitly, or Windows Store builds will get a wrong default value (false)
            sfs.ThreadSafeMode = true;

            sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
            sfs.AddEventListener(SFSEvent.CONNECTION_LOST, OnConnectionLost);
            sfs.AddEventListener(SFSEvent.CRYPTO_INIT, OnCryptoInit);
            sfs.AddEventListener(SFSEvent.LOGIN, OnLogin);
            sfs.AddEventListener(SFSEvent.LOGIN_ERROR, OnLoginError);
            sfs.AddEventListener(SFSEvent.PING_PONG, OnPingPong);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN, OnJoinRoom);
            sfs.AddEventListener(SFSEvent.ROOM_JOIN_ERROR, OnJoinRoomError);
            sfs.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
            sfs.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
            sfs.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, OnRoomVariableUpdated);

            sfs.AddLogListener(LogLevel.DEBUG, OnDebugMessage);
            sfs.AddLogListener(LogLevel.INFO, OnInfoMessage);
            sfs.AddLogListener(LogLevel.WARN, OnWarnMessage);
            sfs.AddLogListener(LogLevel.ERROR, OnErrorMessage);

            // Set connection parameters
            ConfigData cfg = new ConfigData();
            cfg.Host      = hostInput.text;
            cfg.Port      = Convert.ToInt32(portInput.text);
            cfg.HttpPort  = httpPort;
            cfg.HttpsPort = httpsPort;
            cfg.Zone      = "BasicExamples";
            cfg.Debug     = debugToggle.isOn;

            // Connect to SFS2X
            sfs.Connect(cfg);
        }
        else
        {
            // DISCONNECT

            // Disable button
            button.interactable = false;

            // Disconnect from SFS2X
            sfs.Disconnect();
        }
    }
Esempio n. 60
0
    // Use this for initialization
    void Start()
    {
        isBlueTeam = gameObject.GetComponent<GameManager>().IsBlueTeam;

        redResultsStyle = new GUIStyle();
        redResultsStyle.fontSize = 24;
        redResultsStyle.alignment = TextAnchor.MiddleCenter;

        titleStyle = new GUIStyle();
        titleStyle.fontSize = 36;
        titleStyle.alignment = TextAnchor.MiddleCenter;
        titleStyle.normal.textColor = Color.white;

        roundStyle = new GUIStyle();
        roundStyle.fontSize = 24;
        roundStyle.alignment = TextAnchor.MiddleCenter;
        roundStyle.normal.textColor = Color.white;

        if (isBlueTeam)
        {
            //teamColor = new Color(68, 137, 223, 1.0f);
            teamColor = new Color(0.27f, 0.54f, 0.87f, 1.0f);
        }
        else
        {
            //teamColor = new Color(226, 40, 32, 1.0f);
            teamColor = new Color(0.87f, 0.16f, 0.13f, 1.0f);
        }

        winnerStyle = new GUIStyle();
        winnerStyle.fontSize = 36;
        winnerStyle.alignment = TextAnchor.MiddleCenter;
        winnerStyle.normal.textColor = teamColor;

        redResultsStyle.normal.textColor = Color.red;

        blueResultsStyle = new GUIStyle();
        blueResultsStyle.fontSize = 24;
        blueResultsStyle.alignment = TextAnchor.MiddleCenter;
        blueResultsStyle.normal.textColor = Color.blue;

        smartFox = SmartFoxConnection.Connection;

        _redPoints = smartFox.LastJoinedRoom.GetVariable("redStored").GetIntValue();
        _redTotal = smartFox.LastJoinedRoom.GetVariable("redTotalScore").GetIntValue();
        _bluePoints = smartFox.LastJoinedRoom.GetVariable("blueStored").GetIntValue();
        _blueTotal = smartFox.LastJoinedRoom.GetVariable("blueTotalScore").GetIntValue();

        _roundString = string.Format("Round {0}/{1} completed",
            smartFox.LastJoinedRoom.GetVariable("currentRound").GetIntValue(),
            smartFox.LastJoinedRoom.GetVariable("rounds").GetIntValue());
        _winnerString = _redTotal > _blueTotal ? "Red won!" : _redTotal == _blueTotal ? "'Twas a tie!" : "Blue won!";
        _matchOver = smartFox.LastJoinedRoom.GetVariable("currentRound").GetIntValue()
            == smartFox.LastJoinedRoom.GetVariable("rounds").GetIntValue();

        smartFox.AddEventListener(SFSEvent.ROOM_VARIABLES_UPDATE, onRoomVarUpdate);

        startTime = Time.time;
        lastUpdateTime = startTime;
    }