import { WebCommunicator } from "../communicator/WebCommunicator"; import { IServerConnector } from "../IServerConnector"; import { IProtocol } from "../../invoke/IProtocol"; import { Invoke } from "../../invoke/Invoke"; /** * A server connector for web-socket protocol. * * {@link WebServerConnector} is a class connecting to remote server who follows Web-socket protocol and taking full * charge of network communication with the remote server. Create an {@link WebServerConnector} instance from the * {@IProtocol listener} and call the {@link connect connect()} method. * * #### [Inherited] {@link IServerConnector} * @copydoc IServerConnector */ export declare class WebServerConnector extends WebCommunicator implements IServerConnector { /** * @hidden */ private browser_socket_; /** * @hidden */ private node_client_; /** * @inheritdoc */ onConnect: Function; /** * Construct from *listener*. * * @param listener A listener object to listen replied message from newly connected client in * {@link IProtocol.replyData replyData()} as an {@link Invoke} object. */ constructor(listener: IProtocol); /** * Connect to a web server. * * Connects to a server with specified *host* address, *port* number and *path*. After the connection has * succeeded, callback function {@link onConnect} is called. Listening data from the connected server also begins. * Replied messages from the connected server will be converted to {@link Invoke} classes and will be shifted to * the {@link WebCommunicator.listener listener}'s {@link IProtocol.replyData replyData()} method. * * If the connection fails immediately, either an event is dispatched or an exception is thrown: an error * event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, * the status of the connection is reported by an event. If the socket is already connected, the existing * connection is closed first. * * @param ip The name or IP address of the host to connect to. * If no host is specified, the host that is contacted is the host where the calling file resides. * If you do not specify a host, use an event listener to determine whether the connection was * successful. * @param port The port number to connect to. * @param path Path of service which you want. */ connect(ip: string, port: number, path?: string): void; /** * @inheritdoc */ close(): void; /** * @inheritdoc */ sendData(invoke: Invoke): void; /** * @hidden */ private _Handle_browser_connect; /** * @hidden */ private _Handle_browser_message; /** * @hidden */ private _Handle_node_connect; }