I've recently started using ngx-socket-io, and i've run into some difficultys as i wanted to retreive the socket id. Does anyone know how this can be done ? (I'm using the service intialization not the one in the app Module) Thank you in advance.
Retreive socket id from ngx-socket-io
778 Views Asked by Syler At
2
There are 2 best solutions below
0
zos1000
On
You can find it in the socket instance: socket.ioSocket.id.
However you will have to wait for the socket to initialize before using it.
@Injectable({ providedIn: 'root' })
export class SocketService {
socketId;
constructor(private socket: Socket) {
socket.on('connect', () => this.socketId = this.socket.ioSocket.id);
}
}
Related Questions in ANGULAR
- Firebase link existing user to anonymous account?
- It doesnt always show all the books on my homepage
- Google adsense ads.txt status cannot be not found
- When I navigate to the URL'http://localhost:4200/', it redirects me back
- Ionic Angular Standalone ion-icon are not showing at all
- How to make Angular understand that view child is of a specific type, not a general ElementRef?
- vscode, debug angular, first time, doesn't debug, 2nd time stops at main.js then it's ok
- How to perform CRUD operations on a static JSON array in Angular? (without API)
- Ngrx props<>() method in createAction()
- How to animate rotation of an image inside input control?
- Detecting click inside and outside of the listening component in Angular
- Angular - type guard not narrowing types
- In node_modules file i am getting Angular genric error while using fontawesome in angular12
- Angular 16 sending null values to API
- GoogleCloud Error: Not Found The requested URL was not found on this server
Related Questions in IONIC-FRAMEWORK
- Firebase link existing user to anonymous account?
- Ionic Angular Standalone ion-icon are not showing at all
- Unable to run ionic app on Android emulator - [error] ADBs is unresponsive after 5000ms
- How should I filter Observables the "Right Way" with RxJs in Angular 17?
- Ionic/Capacitor: Background Location Tracking on iOS and Android?
- Best Approach for Implementing Video Selection from Gallery/Files in Ionic-React with Capacitor
- <video> tag with downloaded path in ionic ios not loads the video
- How do I record that this ionic checkbox has been checked by the user?
- Ionic 5 angular sharing a component between two modules
- mergeDebugResources FAILED
- Issue saving generated image to local filesystem in iOS using Capacitor
- Detect clickable areas within <img> tag in Ionic project
- Whitelisting Ionic app in Salesforce Org for CORS/CSP
- How to Polyfill node core modules in webpack 5 using ionic capacitor angular
- I'm developing an Android, but I can't see my "console.log" in logcat
Related Questions in SOCKET.IO
- How to Socket.IO Multithreading on a Raspberry Pi?
- Error while uploading the socket io chat app
- Socket.io nodejs server .NET connection
- Getting an error in Socket.io wordle project
- User is connecting to socket.io server twice
- Using Bun+Elysia+socket.io together
- Socket.io event doesn't emitting from client itself client
- Socket.io not emitting event to node server on react native
- My socket.io web socket application is not sending data to some users
- Web RTC simple peer connection with socket.io could not be established
- socket io working fine on local environment but causes problem when run using deployed site
- rasa not responding when setting the value of session_persistence: true using socket
- open-telemetry observable gauge in js - how to access field used in observable gauge inside socket.io method
- Socket io not working during deployment on vercel
- Socket.io Deployment
Related Questions in NGX-SOCKET-IO
- Angular V17-SSR-ERROR Error: NullInjectorError: No provider for WrappedSocket
- Ionic, socket.io-stream and ngx-socket-io
- Nodejs Socketio server socket.emit nor io.emit working but socket.on does
- Ionic 6, upgrade Angular version from 13 to 15
- Ionic websocket library socket io emit and fromevent methods not working
- exception handling in ngx-socket-io angular
- Dynamically adding a parameter to socket initialization in ngx-socket-io
- Retreive socket id from ngx-socket-io
- Ionic App is crashing with Ngrx and ngx-socket-io
- Change socketio config dynamically
- How to send credentials with ngx-socket-io?
- angular client 'server error' on connection to netty-socket.io server
- Angular tests, socket.io "NullInjectorError: No provider for WrappedSocket"
- ngx-socket-io connected false but flask_socketio logs show 200 OK
- Why socket.io returns "Bad handshake method"?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?