Ejemplo n.º 1
0
    public void OnButtonConnect()
    {
        if (session != null)
        {
            FunapiSession.Destroy(session);
            session = null;
        }

        // Create session
        SessionOption option = new SessionOption();

        option.sessionReliability    = false;
        option.sendSessionIdOnlyOnce = false;

        session = FunapiSession.Create(address.text, option);
        session.SessionEventCallback    += onSessionEvent;
        session.TransportEventCallback  += onTransportEvent;
        session.TransportErrorCallback  += onTransportError;
        session.ReceivedMessageCallback += onReceivedMessage;

        if (protocol1.type != TransportProtocol.kDefault)
        {
            session.Connect(protocol1.type, encoding1.type, ushort.Parse(port1.text));
        }

        if (protocol2.type != TransportProtocol.kDefault)
        {
            session.Connect(protocol2.type, encoding2.type, ushort.Parse(port2.text));
        }

        if (protocol3.type != TransportProtocol.kDefault)
        {
            session.Connect(protocol3.type, encoding3.type, ushort.Parse(port3.text));
        }
    }
Ejemplo n.º 2
0
    public override void Connect(string host)
    {
        _session = FunapiSession.Create(host);
        _session.ReceivedMessageCallback += this.onMessageReceived;
        _session.SessionEventCallback    += this.onSessionEvent;
        _session.TransportEventCallback  += this.onTransportEvent;

        _session.Connect(TransportProtocol.kTcp, FunEncoding.kProtobuf, 8012);
    }
Ejemplo n.º 3
0
    void createSession()
    {
        if (session_ != null)
        {
            return;
        }

        session_ = FunapiSession.Create(serverAddress, sessionReliability);
        session_.SessionEventCallback   += onSessionEvent;
        session_.TransportEventCallback += onTransportEvent;

        tryConnect(TransportProtocol.kTcp);
        tryConnect(TransportProtocol.kUdp);
        tryConnect(TransportProtocol.kHttp);
    }
    void createSession()
    {
        // Create session
        SessionOption option = new SessionOption();

        option.sessionReliability    = false;
        option.sendSessionIdOnlyOnce = false;

        session = FunapiSession.Create(info.address, option);
        session.SessionEventCallback    += onSessionEvent;
        session.TransportEventCallback  += onTransportEvent;
        session.TransportErrorCallback  += onTransportError;
        session.ReceivedMessageCallback += onReceivedMessage;

        address_changed = false;
    }
Ejemplo n.º 5
0
        public void Connect(bool session_reliability)
        {
            message_number_ = 0;

            if (session_ == null)
            {
                session_ = FunapiSession.Create(server_ip_, session_reliability);
                session_.SessionEventCallback    += onSessionEvent;
                session_.TransportEventCallback  += onTransportEvent;
                session_.TransportErrorCallback  += onTransportError;
                session_.ReceivedMessageCallback += onReceivedMessage;

                for (int i = 0; i < 3; ++i)
                {
                    TransportOption option = new TransportOption();
                    if (protocols[i] == TransportProtocol.kTcp)
                    {
                        TcpTransportOption tcp_option = new TcpTransportOption();
                        tcp_option.EnablePing          = true;
                        tcp_option.PingIntervalSeconds = 1;
                        tcp_option.PingTimeoutSeconds  = 3;
                        option = tcp_option;
                    }
                    else
                    {
                        option = new TransportOption();
                    }

                    option.ConnectionTimeout = 3f;

                    //if (protocols[i] == TransportProtocol.kTcp)
                    //    option.Encryption = EncryptionType.kIFunEngine1Encryption;
                    //else
                    //    option.Encryption = EncryptionType.kIFunEngine2Encryption;

                    ushort port = getPort(protocols[i], encodings[i]);
                    session_.Connect(protocols[i], encodings[i], port, option);
                }
            }
            else
            {
                for (int i = 0; i < 3; ++i)
                {
                    session_.Connect(protocols[i]);
                }
            }
        }
Ejemplo n.º 6
0
        public void Connect(TransportProtocol protocol, FunEncoding encoding)
        {
            if (session == null)
            {
                SessionOption option = new SessionOption();
                option.sessionReliability    = false;
                option.sendSessionIdOnlyOnce = false;

                session = FunapiSession.Create(address, option);
                session.SessionEventCallback    += onSessionEvent;
                session.TransportEventCallback  += onTransportEvent;
                session.TransportErrorCallback  += onTransportError;
                session.ReceivedMessageCallback += onReceivedMessage;
            }

            session.Connect(protocol, encoding, getPort(protocol, encoding));
        }
    public void StartClient(string server_ip, ushort port, string user_id)
    {
        user_id_ = user_id;

        GameObject panel = GameObject.Find("MainPanel");

        if (panel != null)
        {
            mainMenu = panel.GetComponent <LobbyMainMenu>();
        }

        session_ = FunapiSession.Create(server_ip);
        session_.TransportEventCallback  += onTransportEvent;
        session_.ReceivedMessageCallback += onReceived;

        TcpTransportOption option = new TcpTransportOption();

        option.ConnectionTimeout = 10f;

        session_.Connect(TransportProtocol.kTcp, FunEncoding.kJson, port, option);
    }
    void Awake()
    {
        session_ = FunapiSession.Create(server_ip_);
        session_.SessionEventCallback    += OnSessionEvent;
        session_.ReceivedMessageCallback += OnReceive;

        session_.Connect(protocol_, encoding_, port_);

        // Initialize facebook
        facebook_ = GameObject.Find("SocialNetwork").GetComponent <FacebookConnector>();

        // If you don't want to download profile photos with a friend list,
        // set this value to false. The default value is ture.
        //facebook_.AutoDownloadPicture = false;

        facebook_.OnEventCallback     += new SocialNetwork.EventHandler(OnEventHandler);
        facebook_.OnPictureDownloaded += delegate(SocialNetwork.UserInfo user)
        {
            if (!logged_in_)
            {
                return;
            }

            if (image_ != null && user.picture != null)
            {
                image_.texture = user.picture;
            }
        };

        facebook_.Init();

        // Initialize UI
        login_button_ = GameObject.Find("BtnLogin").GetComponent <Button>();
        image_        = GameObject.Find("imgProfile").GetComponent <RawImage>();

        login_button_.interactable = false;
        setButtonState(false);
    }