다음을 통해 공유


IHubProtocol interface

A protocol abstraction for communicating with SignalR Hubs.

Properties

name

The name of the protocol. This is used by SignalR to resolve the protocol between the client and server.

transferFormat

The TransferFormat of the protocol.

version

The version of the protocol.

Methods

parseMessages(string | ArrayBuffer, ILogger)

Creates an array of HubMessage objects from the specified serialized representation. If transferFormat is 'Text', the input parameter must be a string, otherwise it must be an ArrayBuffer.

writeMessage(HubMessage)

Writes the specified HubMessage to a string or ArrayBuffer and returns it. If transferFormat is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.

Property Details

name

The name of the protocol. This is used by SignalR to resolve the protocol between the client and server.

name: string

Property Value

string

transferFormat

The TransferFormat of the protocol.

transferFormat: TransferFormat

Property Value

version

The version of the protocol.

version: number

Property Value

number

Method Details

parseMessages(string | ArrayBuffer, ILogger)

Creates an array of HubMessage objects from the specified serialized representation. If transferFormat is 'Text', the input parameter must be a string, otherwise it must be an ArrayBuffer.

function parseMessages(input: string | ArrayBuffer, logger: ILogger): HubMessage[]

Parameters

input

string | ArrayBuffer

A string or ArrayBuffer containing the serialized representation.

logger
ILogger

A logger that will be used to log messages that occur during parsing.

Returns

writeMessage(HubMessage)

Writes the specified HubMessage to a string or ArrayBuffer and returns it. If transferFormat is 'Text', the result of this method will be a string, otherwise it will be an ArrayBuffer.

function writeMessage(message: HubMessage): string | ArrayBuffer

Parameters

message
HubMessage

The message to write.

Returns

string | ArrayBuffer

A string or ArrayBuffer containing the serialized representation of the message.