#if !BESTHTTP_DISABLE_SIGNALR_CORE && !BESTHTTP_DISABLE_WEBSOCKET
using System;
using System.Collections.Generic;
namespace BestHTTP.SignalRCore
{
public enum TransportTypes
{
WebSocket
}
public enum TransferModes
{
Binary,
Text
}
public enum TransportStates
{
Initial,
Connecting,
Connected,
Closing,
Failed,
Closed
}
///
/// Possible states of a HubConnection
///
public enum ConnectionStates
{
Initial,
Authenticating,
Negotiating,
Connected,
CloseInitiated,
Closed
}
public interface ITransport
{
TransferModes TransferMode { get; }
TransportTypes TransportType { get; }
TransportStates State { get; }
string ErrorReason { get; }
event Action OnStateChanged;
void StartConnect();
void StartClose();
void Send(byte[] msg);
}
public interface IEncoder
{
string Name { get; }
string EncodeAsText(T value);
T DecodeAs(string text);
byte[] EncodeAsBinary(T value);
T DecodeAs(byte[] data);
object ConvertTo(Type toType, object obj);
}
public class StreamItemContainer
{
public readonly long id;
public List Items { get; private set; }
public T LastAdded { get; private set; }
//public int newIdx;
//public int newCount;
public bool IsCanceled;
public StreamItemContainer(long _id)
{
this.id = _id;
this.Items = new List();
}
public void AddItem(T item)
{
if (this.Items == null)
this.Items = new List();
//this.newIdx = this.Items.Count;
//this.newCount = 1;
this.Items.Add(item);
this.LastAdded = item;
}
//public void AddItems(T[] items)
//{
// if (this.Items == null)
// this.Items = new List();
//
// this.newIdx = this.Items.Count;
// this.newCount = items.Length;
//
// this.Items.AddRange(items);
//}
}
struct CallbackDescriptor
{
public readonly Type[] ParamTypes;
public readonly Action