1234567891011121314151617181920212223242526272829303132 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- namespace KairoEngine.Multiplayer
- {
- public class ClientHandshakeController : MonoBehaviour
- {
- public ClientBehaviour client;
-
- private void Awake()
- {
- GenericEvents.StartListening($"{client.eventStreamName}_Connected", OnEvent);
- }
- private void OnDestroy()
- {
- GenericEvents.StopListening($"{client.eventStreamName}_Connected", OnEvent);
- }
- private void OnEvent(string text)
- {
- if(client == null) return;
- NetHandshakeMsg handshakeMsg = new NetHandshakeMsg();
- handshakeMsg.playerName = client.playerName;
- Timer.ExecuteRealTime(100, ()=> {
- client.SendNetMsgToServer(((uint)NetOpCode.Handshake), handshakeMsg);
- });
- }
- }
- }
|