{"id":23701151,"url":"https://github.com/ehanlin/socket-subscriber","last_synced_at":"2026-01-29T10:30:15.698Z","repository":{"id":57365103,"uuid":"71884155","full_name":"eHanlin/socket-subscriber","owner":"eHanlin","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-06T08:52:36.000Z","size":293,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-23T09:02:45.828Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eHanlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-25T10:04:26.000Z","updated_at":"2016-10-25T10:04:43.000Z","dependencies_parsed_at":"2022-09-13T21:11:55.379Z","dependency_job_id":null,"html_url":"https://github.com/eHanlin/socket-subscriber","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fsocket-subscriber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fsocket-subscriber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fsocket-subscriber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eHanlin%2Fsocket-subscriber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eHanlin","download_url":"https://codeload.github.com/eHanlin/socket-subscriber/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239776626,"owners_count":19695143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-30T09:32:18.586Z","updated_at":"2026-01-29T10:30:15.640Z","avatar_url":"https://github.com/eHanlin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"socket-subscriber\n=====================================\n\n## Demo\n\n[demo page](https://ehanlin.github.io/socket-subscriber/demo/index.html)\n\n## Usage\n\nCreate a instance.\n```js\nvar client = new SocketSubscriber(url, {debug:true});\n```\n\nRegister connect and error events.\n```js\nclient.on('connect', ()=\u003e console.log('connection')); \nclient.on('close', ()=\u003e console.log('close'));\n```\n\nSubscribe a room with register listener.\n```js\nclient.room('type', 'id').on((evt)=\u003e console.log(evt));\n```\n\nSubscribe a date pusher with register listener.\n\n```js\nclient.date().on((evt)=\u003e console.log(evt));\n``` \n\nSend a message to room.\n```js\nclient.sendRoom('type', 'id', data);\n```\n\n## Event\n\n* connect\n* close\n* idle\n\n## API\n\n### SocketSubscriber(url:string, opts:object?)\n\u003e opts.debug(boolean)： Trace logs. (default:false)\n\n\u003e opts.retryCount(Number): The value is retring count. The connection is not retring if value is 0. And value \u003c 0 will retry to connect success. (default: 10000)\n\n\u003e opts.retryTime(Number): Retry delay time. (default: -1)\n\n\u003e opts.idleTime(Number): Set idle time. (default: 600000)\n\n\u003e opts.incomingHeartbeat(Number): Set headrtbeat from server. (default: 1000 ms)\n\n* on(evtName:string, listener:function)\n* off(evtName:string, listener:function)\n* debug(enabled:boolean)\n* date() : Channel\n* room(type:string, id:string) : Channel\n* exitRoom(type:string ,id: string)\n* sendRoom(type:string, id:string, label:string?, data:object?, headers: object?)\n* getSockJSSessionId():string\n\n### Channel\n\n* on(evtName:string?, listener:function):Channel\n* off(evtName:string?, listener:function):Channel\n\n## Run dev\n\n```sh\nnpm run dev\n```\n\n## Build\n\n```sh\nnpm run build\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehanlin%2Fsocket-subscriber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehanlin%2Fsocket-subscriber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehanlin%2Fsocket-subscriber/lists"}