{"id":15046198,"url":"https://github.com/jcaguilera/nativescript-betterwebsockets","last_synced_at":"2026-02-13T14:12:22.447Z","repository":{"id":57308426,"uuid":"148933305","full_name":"JCAguilera/nativescript-betterwebsockets","owner":"JCAguilera","description":"A Client and Server WebSockets plugin for Nativescript on Android.","archived":false,"fork":false,"pushed_at":"2018-09-18T19:57:34.000Z","size":2662,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-20T13:22:38.524Z","etag":null,"topics":["android","nativescript","websocket-client","websocket-server","websockets"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/JCAguilera.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-15T19:28:04.000Z","updated_at":"2024-05-30T16:52:53.000Z","dependencies_parsed_at":"2022-09-16T02:24:08.211Z","dependency_job_id":null,"html_url":"https://github.com/JCAguilera/nativescript-betterwebsockets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCAguilera%2Fnativescript-betterwebsockets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCAguilera%2Fnativescript-betterwebsockets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCAguilera%2Fnativescript-betterwebsockets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCAguilera%2Fnativescript-betterwebsockets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JCAguilera","download_url":"https://codeload.github.com/JCAguilera/nativescript-betterwebsockets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234794548,"owners_count":18887753,"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":["android","nativescript","websocket-client","websocket-server","websockets"],"created_at":"2024-09-24T20:52:50.392Z","updated_at":"2026-02-13T14:12:22.408Z","avatar_url":"https://github.com/JCAguilera.png","language":"TypeScript","readme":"\n#  BetterWebsockets for Nativescript\n\n[Java WebSockets](https://github.com/TooTallNate/Java-WebSocket) Library implementation for Nativescript. Allows you to create a WebSocket Client and Server on Android.\n\n[![PayPal Donation](https://img.shields.io/badge/Donate-PayPal-brightgreen.svg)](https://www.paypal.me/JCAguilera) [![Bitcoin Donation](https://img.shields.io/badge/Donate-Bitcoin-orange.svg)](https://juankyapps.com/donate) [![Other Donation Methods](https://img.shields.io/badge/Donate-Others-blue.svg)](https://juankyapps.com/donate)\n\n## Requirements\n  \nThis plugin works on Android only!\n\n## Installation\n\n```javascript\ntns plugin add nativescript-betterwebsockets\n```\n## Usage\n```javascript\nimport { WebSocketClient, WebSocketServer } from 'nativescript-betterwebsockets';  \n```\n**WebSocketClient:**\n```javascript\n/** Inside your page component **/\nlet url = 'wss://echo.websocket.org';\nthis.client = new WebSocketClient(url);\n// Open Event\nthis.client.on('open', function(handshake){\n    console.log('Opened!');\n    this.main(); // Do everything else here\n});\n// Message Event\nthis.client.on('message', function(message){ \n    console.log('New message: ' + message);\n});\n// Close Event\nthis.client.on('close', function(code, reason, remote){\n    console.log('Closed!');\n});\n// Error Event\nthis.client.on('error', function(ex){\n    console.log('Error!');\n});\n// Connect (Do after setting the events!).\nthis.client.connect();\n```\n```javascript\n// This will be executed after the open event.\nmain() {\n    // To prevent crashes, send messages after the socket is opened.\n    this.client.send('Hey!');\n    this.client.close(); // Close the client :(\n}\n```\nOther WebSocketClient methods are avaliable [here](https://static.javadoc.io/org.java-websocket/Java-WebSocket/1.3.9/org/java_websocket/client/WebSocketClient.html).\n\n**WebSocketServer:**\n```javascript\nlet port = 3000;\nthis.server  =  new  WebSocketServer(port);\n// Start Event (Server Started successfully)\nthis.server.on('start', () =\u003e {\n    console.log('Server listening on *:'  +  port);\n});\n// Open Event (Someone connects)\nthis.server.on('open', (conn, handshake) =\u003e {\n    console.log('New Conenction!');\n    conn.send('You are connected!'); // Send message to socket\n});\n// Message Event\nthis.server.on('message', (conn, message) =\u003e {\n    console.log('New message: ' + message);\n});\n// Close event\nthis.server.on('close', (conn, code, reason, remote) =\u003e {\n    console.log('Someone left!');\n});\n// Error event\nthis.server.on('error', (conn, ex) =\u003e {\n    console.log('Error!');\n});\n// Starts the server\nthis.server.start();\n```\nOther WebSocketServer methods are avaliable [here](https://static.javadoc.io/org.java-websocket/Java-WebSocket/1.3.9/org/java_websocket/server/WebSocketServer.html).\n## License\n\nMIT License - see [LICENSE](LICENSE) for more details.\n","funding_links":["https://www.paypal.me/JCAguilera"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcaguilera%2Fnativescript-betterwebsockets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcaguilera%2Fnativescript-betterwebsockets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcaguilera%2Fnativescript-betterwebsockets/lists"}