47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using BestHTTP.WebSocket;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// websocket通信
|
|
/// </summary>
|
|
public interface IWebSocketChannle: IApplcationShutdown
|
|
{
|
|
WebSocket _webSocket { get;}
|
|
bool IsConnected { get; }
|
|
string Description { get; }
|
|
|
|
string _url { get; }
|
|
event OnCloseEvent _closeEvent;
|
|
event OnMessageEvent _messageEvent;
|
|
Dictionary<WebSocketChannleKey, OnMessageEvent> messageMap { get; }
|
|
event OnErrorEvent _errorEvent;
|
|
delegate void OnMessageEvent(object data,object other = null);
|
|
delegate void OnCloseEvent();
|
|
delegate void OnErrorEvent();
|
|
/// <summary>
|
|
/// websock 消息监听
|
|
/// </summary>
|
|
/// <param name="onMessage"></param>
|
|
public void OnMessage(OnMessageEvent onMessage);
|
|
public void OnMessage(WebSocketChannleKey key, OnMessageEvent onMessage);
|
|
/// <summary>
|
|
/// websock 关闭监听
|
|
/// </summary>
|
|
/// <param name="onClose"></param>
|
|
public void OnClose(OnCloseEvent onClose);
|
|
/// <summary>
|
|
/// websock 异常错误监听
|
|
/// </summary>
|
|
/// <param name="onError"></param>
|
|
public void OnError(OnErrorEvent onError);
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="onMessage"></param>
|
|
public void Connect();
|
|
|
|
}
|