UNPKG

@parkersoftware/whoson-lib

Version:

Useful whoson related library

329 lines (328 loc) 11.8 kB
import { Hooks } from "./Hooks"; export declare class WhosOnSocket { private _hooks; private _showMessages; private _socket; private _loggedOut; private _supportsAck; /** * @constructor * @param {string} address - The address we want to connect to * @param {Hooks} _hooks - Hook dependency */ constructor(address: string, _hooks: Hooks); /** * connect to the whoson server * @param {string} address - The websocket address of the whoson server */ connect(address?: string): void; /** * Login with a user name and password * @param auth The server operator authentication string * @param displayName The display name of the operator logging in * @param department The department of the operator * @param phone The phone details of the operator * @param version Version of the platform * @param status The inital status of the operator * @param lang The language code of the operator * @param platform The current platform - "WebClient" * @param userName The username of the operator * @param password The password of the operator * @param apiKey The server API key */ login(auth: string, displayName: string, department: string, phone: string, version: string, status: string, lang: string, platform: string, userName: string, password: string, apiKey: string): void; /** * Authenticate with a username and password * @param username * @param password * @param apiKey */ authenticate(username: string, password: string, apiKey: string): void; /** * @deprecated old way of authenticating - do not use * @param username * @param token * @param apiKey */ authenticateToken(username: string, token: string, apiKey: string): void; /** * Authenticate with the whoson server with a session token * @param username * @param token * @param apiKey */ authenticateBySession(username: string, token: string, apiKey: string): void; /** * Begin the process of authenticating a user to check if openid is supported * @param username the username to check with the server to see if openid is used. * @param baseUrl the base url to use for any redirect parameters. usually window.location.origin. */ checkOpenIdAuthentication(username: string, baseUrl: string): void; /** * Accept a chat by its number * @param chatNum Number of the chat */ acceptChat(chatNum: number): void; /** * Close a chat * @param chatNum */ closeChat(chatNum: number): void; /** * Send a message to a chat * @param chatNum Number of the chat * @param message Contents to send */ sendMessage(chatNum: number, message: string): void; /** * Send typing status to chat * @param chatNum Number of the chat */ sendTypingStatus(chatNum: number): void; /** * Stop the typing status to a chat * @param chatNum Number of the chat */ stopTypingStatus(chatNum: number): void; /** * Get the avatar/photo of the user * @param userName Username to get */ getUserPhoto(userName: string): void; /** * Transfering a chat to * @param chatNum The chat number * @param connectionIds Client connection IDs to send the transfer request to * @param message message to send along to with the request */ transferChat(chatNum: number, connectionIds: number[], message: string): void; /** * Transfer chat to a department * @param chatNum Chat to transfer to * @param department Department to transfer to * @param message Contents to send along with the request */ transferChatToDept(chatNum: number, department: string, message: string): void; /** * Transfer chat to a skill * @param chatNum Chat to transfer to * @param skillId Skill Id to transfer to * @param message Contents to send along with the request */ transferChatToSkill(chatNum: number, skillId: string, message: string): void; /** * Leave a chat * @param chatNum chat number to leave */ leaveChat(chatNum: number): void; /** * Monitor a chat * @param chatNum chat number to monitor */ monitorChat(chatNum: number): void; /** * Stop monitoring a chat * @param chatNum chat number to monitor */ stopMonitoringChat(chatNum: number): void; /** * Whisper to a operator in a chat * @param connectionId operator connection id to send to * @param chatNum chat number of the chat * @param text contents of whisper */ whisper(connectionId: string, chatNum: number, text: string): void; /** * change your status * @param newstatus the new status to change to */ changeStatus(newstatus: string, message: string): void; /** * Get all canned responses */ getCannedResponses(): void; /** * Get all files */ getFiles(): void; /** * Get all skills */ getSkills(): void; /** * get daily summary */ getDailySummary(): void; /** * Get monthly summary of a site * @param siteKey the site you want */ getMonthlySummary(siteKey: number): void; /** * Get previous chats of a site by date * @param sitekey the site you want * @param date the date you want */ getPreviousChats(sitekey: number, date: string): void; /** * Get previous chat by site and it's id * @param sitekey the site of the chat * @param chatid the id of the chat */ getPreviousChat(sitekey: number, chatid: string): void; /** * Request a file from the visitor * @param chatNum the number of the chat to request from */ requestFile(chatNum: number): void; /** * Send a file to the visitor * @param chatNum the chat number * @param fileName name of the file to send * @param url the url of the file */ sendFile(chatNum: number, fileName: string, url: string): void; /** * Get visitor details * @param siteKey the site key of the visitor * @param ip the ip of the visitor * @param sessionId the visitors session id * @param chatId the chat of the visitor */ getVisitorDetail(siteKey: number, ip: string, sessionId: string, chatId: string): void; /** * Complete the wraup of a chat * @param siteKey sitekey of the chat * @param chatId the chats id * @param value the value of the wrapup */ completeWrapUp(siteKey: number, chatId: string, value: string): void; /** * requests the upscope cobrowse url from the server * current operator must be in a chat and be allowed to use cobrowse tools for success * @param chatId the chatuid of the session to request. */ requestUpscopeUrl(chatId: string): void; /** * Store any settings/options with this * @param options a json object of settings */ clientOptions(options: any): void; /** * Change operator password * @param userName username of the operator * @param oldpassword the old password * @param newpassword the new password. must match old password */ changePassword(userName: string, oldpassword: string, newpassword: string): void; /** * Start the visitor events. WhosOn Server will send a visitor event whenever a new visitor arrives at a site and when a visitor changes (for example, requests a new page or their IP address is resolved to a DNS name, or the visitor becomes a prospect etc). It will send a visitorremoved event whenever a visitor leaves a site. */ startVisitorEvents(): void; /** * Gets all the connected clients */ getClients(): void; /** * get operator to operator chat * @param userName chat with username to get * @param lowestId The lowest id parameter is used for paging. For each GetClientChat command the server will send a maximum of 100 lines. If the lowest id parameter is zero, then the most recent 100 lines will be sent. Each line sent contains an ID. To retrieve more lines, send the GetClientChat command again but with the lowest ID that you last received. * @param searchText text to search */ getClientChat(userName: string, lowestId: string, searchText: string): void; /** * send message to operator * @param connId connection of the operator * @param text message to send */ sendToOperator(connId: string, text: string): void; /** * send file to a operator * @param connId connection of the operator * @param fileName name of the file to send * @param url url of the file to send */ sendFileToOperator(connId: string, fileName: string, url: string): void; /** * Send typing indicator to a operator * @param connId Connection id of the operator */ sendOperatorTypingStatus(connId: string): void; /** * Stop the typing indicator to a operator * @param connId Connection id of the operator */ stopOperatorTypingStatus(connId: string): void; /** * Enable - Once enabled the server will automatically send a ct event when current visitor totals change. */ startCurrentVisitorTotalsEvents(): void; /** * Disable - stops the ct event */ stopCurrentVisitorTotalsEvents(): void; /** * Aquired chat from another operator * @param chatNumber the number of the chat */ aquireChat(chatNumber: number): void; /** * Once enabled all active chat messages are sent to the listening client as they occur. This enables the creation of a 'supervisor view' to monitor the activity of all active chats for all users (that the logged in user has access to). Team Leaders can only see chats that are interacting with users in their own user groups. */ startListening(): void; /** * Disable the listening */ stopListening(): void; /** * Kick a client * @param connId Client number * @param message Message to send to client */ kickOtherOperator(connId: number, message: string): void; /** * Say that your've read the chat for read receipts */ read(): void; /** * Responding to missed chat * @param chatid chat id */ respondingToMissedChat(chatid: string): void; /** * Respond to missed chat * @param chatid chat id * @param text the text to respond with */ respondToMissedChat(chatid: string, text: string): void; /** * Cancel response to missed chat * @param chatid chat id */ cancelResponseToMissedChat(chatid: string): void; /** * Soft close a chat so it can be reopened later * @param connId chat connection */ softCloseChat(connId: number): void; /** * Open a soft closed chat * @param chatId Chat id * @param siteKey site of the chat */ openSoftChat(chatId: string, siteKey: number): void; /** * change status of a user * @param connId connection id of user * @param status status to switch to */ changeStatusOfUser(connId: number, status: string): void; /** * Logout of the server */ logout(): void; /** * Disconnects from the server */ disconnect(): void; }