using System;
using UnityEngine;

//客户端连接到服务器
public class ClientConnectedState : ConnectionState
{
    public override void Enter()
    {
    }

    public override void Exit()
    {
    }

    //服务端断开连接。切换到重连状态ClientReconnectingState
    public override void OnClientDisconnect(ulong clientId)
    {
        //MessageCenter.SendMessage(EventDefine.ConnectStatusEvent, ConnectStatus.Reconnecting);
        m_ConnectionManager.ChangeState(m_ConnectionManager.m_ClientReconnecting);
    }

    //用户主动断开。切换到OfflineState
    public override void OnUserRequestedShutdown()
    {
        MessageCenter.SendMessage(EventDefine.ConnectStatusEvent, ConnectStatus.UserRequestedDisconnect);
        m_ConnectionManager.ChangeState(m_ConnectionManager.m_Offline);
    }

    //服务端断开连接，并附加原因。切换到DisconnectingWithReasonState
    public override void OnDisconnectReasonReceived(ConnectStatus disconnectReason)
    {
        MessageCenter.SendMessage(EventDefine.ConnectStatusEvent, disconnectReason);
        //MessageCenter.SendMessage(EventDefine.ClientDisConnectionEvent, disconnectReason);
        m_ConnectionManager.ChangeState(m_ConnectionManager.m_DisconnectingWithReason);
    }
}
