Coder Social home page Coder Social logo

Comments (3)

JoshuaStrunk avatar JoshuaStrunk commented on September 18, 2024 2

I would argue this does not depend on your scripting runtime (#5).

I envision a more likely scenario being a developer/team has an authoritative environment they are comfortable in and they need to handle some orchestration from it. Basically a way of allowing things to be server/admin API controlled. For things like login/registration allow for a configured secret server/admin key. For anything that is handled through a real-time client connection you could allow for superuser/ admin client connections which can act as though they are any user. Updating data, creating group, games, etc...

Forgive me if this seems silly, have only really been diving into APIs and still need time to actually experiment and test out Nakama to fully understand what is there.

from nakama.

mofirouz avatar mofirouz commented on September 18, 2024

There is also a requirement for some games (e.g. Poker) where a user cannot be logged in multiple times. #132

from nakama.

novabyte avatar novabyte commented on September 18, 2024

This can be achieved with simple server runtime code now. For example:

// Place code inside InitModule
messageIDs := []string{"ChannelJoin", "ChannelLeave", "ChannelMessageSend", "ChannelMessageUpdate", "ChannelMessageRemove", "MatchCreate", "MatchmakerAdd", "MatchmakerRemove", "StatusFollow", "StatusUnfollow", "StatusUpdate"}
rtBeforeDisableMessage := func(ctx context.Context, logger *log.Logger, db *sql.DB, nk runtime.NakamaModule, envelope *rtapi.Envelope) (*rtapi.Envelope, error) {
	return nil, errors.New("disallowed")
}
for _, id := range messageIDs {
	if err := initializer.RegisterBeforeRt(id, rtBeforeDisableMessage); err != nil {
		return err
	}
}

That code example will disable most realtime messages in the socket pipeline. There's equivalent functions to disable features in the API although these are easier to disable with a load balancer in front of the game server as normal.

The equivalent in Lua can be achieved with:

local nk = require("nakama")
local message_ids = {"ChannelJoin", "ChannelLeave", "ChannelMessageSend", "ChannelMessageUpdate", "ChannelMessageRemove", "MatchCreate", "MatchmakerAdd", "MatchmakerRemove", "StatusFollow", "StatusUnfollow", "StatusUpdate"}
local function disable_rt_message(context, payload)
    error("disallowed")
end
for _, message_id in ipairs(message_ids) do
    nk.register_rt_before(disable_rt_message, message_id)
end

It's also possible to disable a user from concurrent play sessions with our streams API. 🏆

from nakama.

Related Issues (20)

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.