Giter Site home page Giter Site logo

colyseus / colyseus-social Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 17.0 505 KB

Authentication and Social features

Home Page: https://docs.colyseus.io/tools/colyseus-social/

License: MIT License

TypeScript 94.61% JavaScript 5.39%
colyseus colyseus-plugin facebook

colyseus-social's Introduction



Discussion forum

Multiplayer Framework for Node.js.
View documentation

Colyseus is an Authoritative Multiplayer Framework for Node.js, with SDKs available for the Web, Unity, Defold, Haxe, Cocos and Construct3. (See official SDKs)

The project focuses on providing synchronizable data structures for realtime and turn-based games, matchmaking, and ease of usage both on the server-side and client-side.

The mission of the framework is to be a standard netcode & matchmaking solution for any kind of project you can think of!

Key features:

  • WebSocket-based communication
  • Simple API in the server-side and client-side.
  • Automatic state synchronization from server-to-client (delta compressed)
  • Matchmaking clients into game rooms/sessions
  • Scale vertically or horizontally

See public roadmap for future plans.

๐Ÿš€ Quickstart

Create a bare-bones Colyseus server by using npm create colyseus-app@latest:

npm create colyseus-app@latest my-colyseus-server
cd my-colyseus-server
npm start

Sponsors

The sustainability of the project relies on Colyseus Cloud subscriptions and sponsorships. If you are not using Colyseus Cloud, please consider sponsoring the project ๐Ÿ’–

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Aymeric Chauvin

๐Ÿ’ฌ ๐Ÿ’ก

Brian Hay

๐Ÿ–‹

Damian A. Pastorini

๐Ÿ’ฌ ๐Ÿ“– ๐Ÿ›

Darek Greenly

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป

David Rydwanski

๐Ÿ’ฌ ๐Ÿ’ป

Dr. Burton

๐Ÿง‘โ€๐Ÿซ

Endel Dreyer

๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก

Enriqueto

๐Ÿ’ผ

Fazri Zubair

๐Ÿ’ผ

Federico

๐Ÿ› ๐Ÿ’ป

James Jacoby

๐Ÿ’ฌ ๐Ÿ’ก ๐Ÿ–‹

Jonas Voland

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป ๐Ÿค” ๐Ÿ’ก

Kyle J. Kemp

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป ๐Ÿค”

Luke Wood

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป

Milad Doorbash

๐Ÿ› ๐Ÿ’ป

Nikita Borisov

๐Ÿ› ๐Ÿ’ป ๐Ÿ’ผ ๐Ÿค”

Phil Harvey

๐Ÿ“–

Sergey

๐Ÿ› ๐Ÿ’ป

Tom

๐Ÿ’ฌ ๐Ÿ› ๐Ÿค”

Tommy Leung

๐Ÿง‘โ€๐Ÿซ

digimbyte

๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind are welcome!

Contributing

We encourage you to contribute to Colyseus! Please check out the Contributing guide for guidelines about how to proceed. Join us!

Everyone interacting in Colyseus and its sub-projects' codebases, issue trackers and chat rooms is expected to follow the code of conduct.

License

MIT

colyseus-social's People

Contributors

chriscauley avatar endel avatar mobyjames avatar tv-t avatar

Stargazers

 avatar  avatar  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  avatar  avatar

colyseus-social's Issues

Registering an user

How would one register a user using email and password? As I can see, there is support only for authorization.

Add MONGODB_URI also

As I see, colyseus-social checks only for the MONGO_URI environmental variable. It would be better to add also MONGODB_URI so that it will work with the MongoDB addon on Heroku out-of-the-box.

OAuth2 support

Hey bit of a feature request but would it be possible to get OAuth2 support for colyseus-social?

conflict with express-basic-auth package

node_modules/express-basic-auth/express-basic-auth.d.ts:48:22 - error TS2430: Interface 'IBasicAuthedRequest' incorrectly extends interface 'Request'.
  Types of property 'auth' are incompatible.
    Property '_id' is missing in type '{ user: string; password: string; }' but required in type 'AuthDataInToken'.

48     export interface IBasicAuthedRequest extends Request {
                        ~~~~~~~~~~~~~~~~~~~

  node_modules/@colyseus/social/src/auth.d.ts:6:5
    6     _id: string;
          ~~~
    '_id' is declared here.


Found 1 error.

Any example?

Is this a separate http service?
I don't understand how to use it.

Any example?

How to send game invites

Without messaging functionality, how could one go about sending invites and creating parties that join rooms together with colyseus-social?

User auth object is empty on Defold Client

I've set up Social going off the docs - I make a login request, and I see the user get generated in MongoDB, but the user never gets back an auth token or anything, the auth table that gets returned is empty (not nil). Am I missing something?

Here's the lua code for making the login call

function NetworkManager:login(username, pw, callback)
	local ip = "ws://127.0.0.1:2567";
	print("Connecting to IP: ", ip);
	self.client = ColyseusClient.new(ip);
	self.client.auth:login({
		email = username,
		password = pw },
		function (err, auth)
			if err == nil then
				print("Auth: ", table.concat(auth));
				callback("SUCCESS")
			else
				callback("FAILED")
			end
		end
	)
end

Custom UserID Support

Hi,

I have an authentication system that provide userIDs.

By anonymous login, Instead of generating ID from the server, I would like to use my ID to login into colyseus-social. From what i see in the source-code, I can send "deviceId" or "platform" to the server, is it possible to post an existing ID to the server as well?

`

queryParams["deviceId"] = GetDeviceId();
queryParams["platform"] = GetPlatform();
		var userData = await Request<UserData>("POST", "/auth", queryParams);

		_id = userData._id;
		Username = userData.Username;
		DisplayName = userData.DisplayName;
		AvatarUrl = userData.AvatarUrl;

		FriendIds = userData.FriendIds;
		BlockedUserIds = userData.BlockedUserIds;

		Token = userData.Token;`

Thanks!

Router.use gets object instead of function when requring socialRoutes

Hi -- I seem to be getting an error in importing (rather requiring) because I am node 9.7.1

Here is the error trace that I am getting:
/home/runner/GamesServer/node_modules/express/lib/router/index.js:458
throw new TypeError('Router.use() requires a middleware function but got a ' + gettype(fn))
^

TypeError: Router.use() requires a middleware function but got a Object
at Function.use (/home/runner/GamesServer/node_modules/express/lib/router/index.js:458:13)
at Function. (/home/runner/GamesServer/node_modules/express/lib/application.js:220:21)
at Array.forEach ()
at Function.use (/home/runner/GamesServer/node_modules/express/lib/application.js:217:7)
at Object. (/home/runner/GamesServer/index.js:58:5)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Unable to connect to mLab MongoDB addon from Heroku

As the title says, I am unable to connect to the mLab MongoDB addon from Heroku. Would be glad to receive any suggestions. My environment variables are as follows:

JWT_SECRET ZSy5CfFW1GiM8xsFtSHA
MONGODB_URI mongodb://heroku_0t3t4std:[email protected]:49433/heroku_0t3t4std
MONGO_URI mongodb://heroku_0t3t4std:[email protected]:49433/heroku_0t3t4std
NODE_OPTIONS --max_old_space_size=20480
NPM_CONFIG_PRODUCTION false

The index.ts:

import http from "http";
import express from "express";
import socialRoutes from "@colyseus/social/express"
import cors from "cors";
import { Server } from "colyseus";
import { monitor } from "@colyseus/monitor";
import GlobalRoom from "./src/room";

const app = express()
app.use(cors());
app.use(express.json())
const server = http.createServer(app);
const gameServer = new Server({
  server,
});
gameServer.define('room', GlobalRoom);

app.use("/", socialRoutes);
app.listen(8080);

// register colyseus monitor AFTER registering your room handlers
/* app.use("/colyseus", monitor()); */

/* const port = Number(process.env.PORT || 2567); */
const port = 7070;
gameServer.listen(port);
console.log(`Listening on ws://localhost:${ port }`)

Logs:

Listening on ws://localhost:7070
2020-04-27T03:15:57.066759+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-04-27T03:15:57.152939+00:00 app[web.1]: Error connecting to database:  MongoNetworkError: failed to connect to server [ds149433.mlab.com:49433] on first connect [MongoNetworkError: connection timed out
2020-04-27T03:15:57.152941+00:00 app[web.1]: at connectionFailureError (/app/node_modules/mongodb/lib/core/connection/connect.js:406:14)
2020-04-27T03:15:57.152942+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connect.js:294:16)
2020-04-27T03:15:57.152942+00:00 app[web.1]: at Object.onceWrapper (events.js:416:28)
2020-04-27T03:15:57.152943+00:00 app[web.1]: at Socket.emit (events.js:310:20)
2020-04-27T03:15:57.152943+00:00 app[web.1]: at Socket.EventEmitter.emit (domain.js:482:12)
2020-04-27T03:15:57.152944+00:00 app[web.1]: at Socket._onTimeout (net.js:479:8)
2020-04-27T03:15:57.152944+00:00 app[web.1]: at listOnTimeout (internal/timers.js:549:17)
2020-04-27T03:15:57.152945+00:00 app[web.1]: at processTimers (internal/timers.js:492:7) {
2020-04-27T03:15:57.152945+00:00 app[web.1]: name: 'MongoNetworkError',
2020-04-27T03:15:57.152945+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-04-27T03:15:57.152946+00:00 app[web.1]: }]
2020-04-27T03:15:57.152946+00:00 app[web.1]: at Pool.<anonymous> (/app/node_modules/mongodb/lib/core/topologies/server.js:438:11)
2020-04-27T03:15:57.152947+00:00 app[web.1]: at Pool.emit (events.js:310:20)
2020-04-27T03:15:57.152947+00:00 app[web.1]: at Pool.EventEmitter.emit (domain.js:482:12)
2020-04-27T03:15:57.152948+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/pool.js:561:14
2020-04-27T03:15:57.152949+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/pool.js:994:11
2020-04-27T03:15:57.152949+00:00 app[web.1]: at /app/node_modules/mongodb/lib/core/connection/connect.js:31:7
2020-04-27T03:15:57.152950+00:00 app[web.1]: at callback (/app/node_modules/mongodb/lib/core/connection/connect.js:264:5)
2020-04-27T03:15:57.152950+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/mongodb/lib/core/connection/connect.js:294:7)
2020-04-27T03:15:57.152951+00:00 app[web.1]: at Object.onceWrapper (events.js:416:28)
2020-04-27T03:15:57.152951+00:00 app[web.1]: at Socket.emit (events.js:310:20)
2020-04-27T03:15:57.152951+00:00 app[web.1]: at Socket.EventEmitter.emit (domain.js:482:12)
2020-04-27T03:15:57.152952+00:00 app[web.1]: at Socket._onTimeout (net.js:479:8)
2020-04-27T03:15:57.152952+00:00 app[web.1]: at listOnTimeout (internal/timers.js:549:17)
2020-04-27T03:15:57.152953+00:00 app[web.1]: at processTimers (internal/timers.js:492:7) {
2020-04-27T03:15:57.152953+00:00 app[web.1]: name: 'MongoNetworkError',
2020-04-27T03:15:57.152954+00:00 app[web.1]: [Symbol(mongoErrorContextSymbol)]: {}
2020-04-27T03:15:57.152954+00:00 app[web.1]: }
2020-04-27T03:16:20.341986+00:00 heroku[web.1]: State changed from crashed to starting
2020-04-27T03:16:20.337781+00:00 heroku[web.1]: State changed from starting to crashed

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.