Code Monkey home page Code Monkey logo

unity3d-ddp-client's Introduction

Unity3D-DDP-Client

A lightweight DDP client for Unity3D. In other words, a library for Unity3D to communicate in realtime with Meteor servers.

I can be used for many things, like account registration, score board, match-making, chat, turn-based games, cooperative tools, etc ...

It may not be a fit for game interactions which require a lot of network data update per second (in which case you may want to use something like UNet instead).

If you are developing for the UWP platform (e.g. for Mixed Reality headsets or XBox) or if you like to use the new .Net 4.6 take a look at the dev branch

Feature list

  • DDP-client:
    • Implementation of the DDP-client protocol version 1.
    • data subscription / notification.
    • method call / response.
    • Uses websocket protocoles ws:// and wss:// to communicate with the server.
    • Does not make assumptions about how to reconnect in case of disconnection. Let the user do it. Example provided.
  • Accounts:
    • Login with username and password, logout.
    • Resume previous session by login using a token.
    • Does not make assumption about how the credentials and loaded and saved, let the user do it instead.
  • Local Database:
    • Is optional.
    • Listens to the DdpConnection and creates collections on demand.
    • Let the user instantiate the database's collection via a callback.
    • Database collections can keep the documents as JSON objects or as custom classes, in which case it let the user provide serialization / deserialization callbacks.
    • Collections can be iterated over, and the user can register to their content's changes.

Getting started

Start the Meteor server

$  curl https://install.meteor.com/ | sh
  • Launch the server:
$ cd example-server
$ meteor

Start one of the Unity3D examples

Read the source code to see how it works and which keys to press.

The code is fairly simple and easy to read, both in the examples and in the library classes.

Stability

The source code is freshly typed and was not fully tested yet. If you find a bug, please file an issue on Github and I will be happy to fix it asap.

The source code is fairly simple, so may you find a bug, a fix should not take very long to implement.

Roadmap

Features to add later:

  • Additional ways to login, maybe using Facebook and Google+.
  • A bigger and complete example project.

Contribute

Contributions are welcome on this project.

Pull requests will be reviewed and may be modified to fit the coding style (i.e. to keep it easy to read).

License

This project is distributed under the MIT license.

unity3d-ddp-client's People

Contributors

brean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity3d-ddp-client's Issues

Is it necessary to unsubscribe before subscribing with new parameters?

For a location-based application, we have to update the subscriptions frequently, i.e. every time a user moves significantly. Is it necessary to unsubscribe in this case before subscribing to the same publication, but with other parameters? Or is it sufficient to just re-subscribe, as it is done in a regular Meteor client?

In the latter case: what happens to event handlers that have been registered on the previous subscription? Will they be automatically purged?

Still maintained?

Is this repo still being maintained? Since the last commit was one year ago, I am wondering if that's either because the code is stable or because it has been abandoned. :-)

Write better examples

It would be nice to write some more impressive examples and post some relevant screenshots on the README.md file.

Can't log in to a Meteor account

Hi,

Thank you very much for this promising project. I tested it with Meteor 1.4.1.1 + Unity 5.4.1f1 and could connect to local and remote Meteor servers, however each attempt to logging in to an account results in an "Incorrect password" error message.

This happens both from Unity with already existing accounts, and from the browser with accounts created within Unity.

Connection is not closed when exiting Unity play mode

The connection is kept open and it still sends and receives data from the server after you exit the play mode (at least on the dev-branch you can still see the ping-pong messages in the console log). This might be expected behaviour when you start the communication from the Inspector but might be inconvenient in most cases when you connect during program runtime.
Close should maybe be called when the object gets destroyed.

Use a namespace for the classes

Currently there is no namespace, that's a little annoying. I will change that once I have time.

Any suggestion for the namespace's name is welcome.

Merge with my code?

Hi @green-coder ,

based on your code I created a DDP-Client implementation that uses UWP for Hololens (see here ). Because this fork did not work with Unity I thought it was best to keep it as separated repo.

However, I just finished a more general version that does not use websocket-sharp but System.Net ClientWebSocket for Unity instead, if you use the experimental .Net 4.6 as well as UWP if it is build for it.
So instead of doing my own thing I could merge this with your code again and present a pull request, maybe as a special branch because it requires 4.6. For the older .Net that is used for most Unity Projects you still need a 3rd-party lib like websocket-sharp.

What do you think?

Send queued messages only after session is continued with token?

At the moment when I am disconnected from the server and I call a method I get an error but the method call is queued and executed as soon as a connection to the server is re-established.

But after reconnecting the user isn't logged in any more. Therefore all the method calls will return an error that the user needs to be logged in.

I tried to use the token to resume the session in ddpConnection.OnConnected but this is too late and the user will be logged in after all the queued messages have been executed.

Is there any way to solve this problem?

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.