Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socket.IO documentation missing $onConnection requirement #656

Open
ghmendonca opened this issue Sep 27, 2019 · 1 comment
Open

Socket.IO documentation missing $onConnection requirement #656

ghmendonca opened this issue Sep 27, 2019 · 1 comment

Comments

@ghmendonca
Copy link

@ghmendonca ghmendonca commented Sep 27, 2019

Information

  • Version: 5.31.4
  • Type: Issue/Story

Description

Looking the documentation, I can see that there is nothing saying that you have to declare the function $onConnection to make your service to work.

If you do not declare the $onConnection function, then when the server starts you will get:

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at list.getWebsocketServices.reduce (C:\Users\Oktagon PC\Documents\raincrow\version-server\node_modules\@tsed\socketio\src\SocketIOModule.ts:67:16)
    at Array.reduce (<anonymous>)
    at SocketIOModule.printSocketEvents (C:\Users\Oktagon PC\Documents\raincrow\version-server\node_modules\@tsed\socketio\src\SocketIOModule.ts:63:46)
    at SocketIOModule.$afterListen (C:\Users\Oktagon PC\Documents\raincrow\version-server\node_modules\@tsed\socketio\src\SocketIOModule.ts:47:12)
    at Map.<anonymous> (C:\Users\Oktagon PC\Documents\raincrow\version-server\node_modules\@tsed\di\src\class\LocalsContainer.ts:15:34)
    at Generator.next (<anonymous>)
    at C:\Users\Oktagon PC\Documents\raincrow\version-server\node_modules\tslib\tslib.js:110:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\Users\Oktagon PC\Documents\raincrow\version-server\node_modules\tslib\tslib.js:106:16)

And of course, your socket service won't work.

Example

import { SocketService, IO } from '@tsed/socketio'

@SocketService('/')
export class VersionSocket {
    constructor(
        @IO
        private io: SocketIO.Server
    ) {

    }

    aFunctionHere() {
        this.io.emit('something')
    }

    // $onConnection() {

    // }
}

Acceptance criteria

  • Improve Socket.IO documentation
@Romakita Romakita added the Improve doc label Nov 7, 2019
@Romakita Romakita added this to the BACKLOG milestone Nov 7, 2019
@stale
Copy link

@stale stale bot commented Oct 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 9, 2020
@Romakita Romakita added pinned and removed wontfix labels Oct 9, 2020
@Romakita Romakita modified the milestones: V5 BACKLOG, V6 Backlog Oct 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.