# SocketIO
Android Device | Android Emulator | iOS Device | iOS Simulator |
---|---|---|---|
✅ | ✅ | ✅ | ✅ |
- SocketIO(...)
- connect(...)
- disconnect(...)
- on(...)
- once(...)
- off(...)
- emit(...)
- joinNamespace(...)
- leaveNamespace(...)
Note
This currently does not yet support Socket:IO v3.x
Please see this (opens new window) for Android
Please see this (opens new window) for iOS
# Installing
ns plugin add @triniwiz/nativescript-socketio
# Usage
import { SocketIO } from '@triniwiz/nativescript-socketio';
const socketIO = new SocketIO(url, opts);
// connect
socketIO.connect();
// emit data
socketIO.emit(event,data);
// listen for events
socketIO.on(event,callback);
# API
# SocketIO(...)
new SocketIO("server-url");
Creates a new SocketIO instance
Param | Type | Required |
---|---|---|
url | string | ❎ |
options | Object | ✅ |
Returns: SocketIO
# connect()
connect(): void;
Connects the instance to the url supplied in the contructor
# disconnect()
disconnect(): void;
Disconnects the instance from the url supplied in the contructor
# on(...)
on(event: string, callback: (...data)=>void): void;
Listen to an event
# once(...)
once(event: string, callback: (...data)=>void): void;
Listen to a one time event
# off(...)
off(event: string): void;
Removes event listener
# emit(...)
emit(event: string, ...payload: any[]): void;
Emits data
# joinNamespace(...)
joinNamespace(namespace: string): void;
Joins a namespace
# leaveNamespace(...)
leaveNamespace(): void;
Leaves the current namespace
← Sinch Splashscreen →