Example #1
0
    public void onConnectButtonPressed()
    {
        if (NwkSystemBase.isServer())
        {
            NwkServer.nwkServer.disconnect();
        }

        if (!NwkClient.isClient())
        {
            Debug.LogWarning("not on client ? can't react to that button");
            return;
        }

        bool clientConnection = NwkClient.nwkClient.isConnected();

        NwkClient.nwkClient.log("clicked : " + btnConnect.GetComponentInChildren <Text>().text + " / is connected ? " + clientConnection);

        if (clientConnection)
        {
            NwkClient.nwkClient.disconnect();
        }
        else
        {
            NwkClient.nwkClient.connectToIpPort(); // ui view button connect
        }
    }
Example #2
0
    protected override void Awake()
    {
        base.Awake();

        nwkClient = this;

        nwkUid = generateUniqNetworkClientId(); // client is generating its UID
    }
Example #3
0
    virtual protected void setup()
    {
        NwkSystemBase nwkCtx = NwkSystemBase.nwkSys;

        nwkClient = nwkCtx as NwkClient;
        nwkServer = nwkCtx as NwkServer;

        enabled = true;
    }
Example #4
0
    protected override void setupModule()
    {
        base.setupModule();

        _client = owner as NwkClient;

        if (_client == null)
        {
            Debug.LogWarning("can't create a " + GetType() + " for non client setup");
            Debug.Log(owner);
            GameObject.Destroy(this);
        }
    }
Example #5
0
    float _sendFrequency; // time interval to send pack to server

    public NwkSyncableData(iNwkPack parent, float freq)
    {
        idCard         = new NwkSyncableId();
        idCard.syncIID = NwkClient.generateUniqId();

        //this is overritten in syncer first message when it's not local
        syncNwkClientUID = NwkClient.nwkUid;

        handle         = parent;
        _sendFrequency = freq;

        resetState();
        //GameObject.FindObjectOfType<NwkSyncer>().sub(parent);
    }
Example #6
0
    public void log(string ct, bool silent = false)
    {
        if (NwkClient.isClient())
        {
            ct = NwkClient.nwkUid + " " + ct;
        }

        Debug.Log(ct);

        NwkUiViewLogs nvLogs = getModule <NwkModViews>()?.getTab <NwkUiViewLogs>();

        if (nvLogs != null)
        {
            if (!silent)
            {
                nvLogs.addLog(ct);
            }
            else
            {
                nvLogs.addRaw(ct);
            }
        }
    }