Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Example of using websocket in NativeScript-Vue

License

NotificationsYou must be signed in to change notification settings

NewbieScripterRepo/nativescript-websocket-example

Repository files navigation

This is a simple example project demonstrating WebSocket implementation in NativeScript Vue. The project shows how to establish WebSocket connections, send messages, and handle incoming messages in a NativeScript Vue application.

Screenshots

App Screenshot

Features

  • WebSocket connection management
  • Real-time message sending and receiving
  • Clean and modern UI with NativeScript styling
  • TypeScript support
  • Echo server integration for testing

Prerequisites

  • Node.js
  • NativeScript CLI
  • Vue.js knowledge

Installation

  1. Clone the repository:
git clone git@github.com:NewbieScripterRepo/nativescript-websocket-example.gitcd nativescript-websocket-example
  1. Install dependencies:
npm install

Usage

  1. Run the application:
ns run android# orns run ios
  1. The application will show a "Connect" button. Tap it to establish a WebSocket connection to the echo server.

  2. Once connected, you can:

    • Type messages in the text field
    • Send messages using the "Send" button
    • View sent and received messages in the text area
    • Disconnect using the "Disconnect" button

Code Structure

The main WebSocket functionality is implemented insrc/components/Home.vue:

  • connect(): Establishes WebSocket connection
  • sendMessage(): Sends messages to the server
  • disconnect(): Closes the WebSocket connection

WebSocket Events

The example handles the following WebSocket events:

  • onopen: Connection established
  • onmessage: Message received
  • onerror: Error handling

Testing

This example uses the public WebSocket echo server (wss://echo.websocket.org/) for testing purposes. In a production environment, you should replace this with your own WebSocket server.

Contributing

Feel free to submit issues and enhancement requests!

License

MIT License

About

Example of using websocket in NativeScript-Vue

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp