GithubHelp home page GithubHelp logo

iamenochchirima / ic-websocket-cdk-mo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from omnia-network/ic-websocket-cdk-mo

0.0 1.0 0.0 983 KB

IC WebSocket CDK for canisters written in Motoko

Shell 0.53% JavaScript 0.15% TypeScript 54.04% Motoko 45.27%

ic-websocket-cdk-mo's Introduction

ic-websocket-cdk-mo

This repository contains the Motoko implementation of IC WebSocket CDK. For more information about IC WebSockets, see IC WebSocket Gateway.

โš ๏ธ This library is still in development and is not ready for production use. Expect breaking changes.

Installation

You can install the library using mops following these steps:

For example, a valid installation script is:

mops add [email protected]
mops add [email protected]
mops add [email protected]
mops add [email protected]
mops add https://github.com/omnia-network/ic-websocket-cdk-mo#1d3320626e3c476632fc46ebdb9b5402e6207999

The ic-websocket-cdk package will be available on mops soon.

Usage

TODO: Add usage instructions

Candid interface

In order for the frontend clients and the Gateway to work properly, the canister must expose some specific methods in its Candid interface, between the custom methods that you've implemented for your logic. A valid Candid interface for the canister is the following:

import "./ws_types.did";

service : {
  "ws_register" : (CanisterWsRegisterArguments) -> (CanisterWsRegisterResult);
  "ws_open" : (CanisterWsOpenArguments) -> (CanisterWsOpenResult);
  "ws_close" : (CanisterWsCloseArguments) -> (CanisterWsCloseResult);
  "ws_message" : (CanisterWsMessageArguments) -> (CanisterWsMessageResult);
  "ws_get_messages" : (CanisterWsGetMessagesArguments) -> (CanisterWsGetMessagesResult) query;
};

This snipped is copied from the service.example.did file and the types imported are defined in the ws_types.did file.

Note: dfx should already generate the Candid interface for you, so you don't need to write it yourself.

Development

The ic-websocket-cdk library implementation can be found in the src folder.

Testing

There are integration tests available: for these tests a local IC replica is set up and the CDK is deployed to a test canister. Tests are written in Node.js and are available in the tests folder.

There's a script that runs the integration tests, taking care of installing the Node.js dependencies, setting up the replica and deploying the canister. To run the script, execute the following command:

./scripts/test_canister.sh

License

TODO: Add a license

Contributing

Feel free to open issues and pull requests.

ic-websocket-cdk-mo's People

Contributors

ilbertt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.