JS CreateRoom plugins

I'm trying to create new room by js sdk 4.0.0.5

In docuentation says I can set plugin name in room options by
roomOptions.Plugins = new string[]

But I don't see it in photon-javascript_SDK.js-file
LoadBalancingClient.prototype.createRoom = function (roomName, options)

I'm trying to put
createRoom("name", {plugins: "MyPlugin"})
or
createRoom("name", {customGameProperties: {plugins: "MyPlugin"}})
but it's not work

My factory is

public IGamePlugin Create(IPluginHost gameHost, string pluginName, Dictionary<string, string> config, out string errorMsg)
        {
            gameHost.LogWarning("!!!: > " + pluginName + " <<");

            IGamePlugin plugin;
            switch (pluginName)
            {
                case "MyPlugin":
                    plugin = new MyPlugin();
                    break;
                default:
                    plugin = new PluginBase(); // default
                    break;
            }
            return plugin.SetupInstance(gameHost, config, out errorMsg) ? plugin : null;
        }
always empty in pluginName. Am I doing something wrong?

Comments

  • Hi,

    'plugins' option is not supported yet in Photon js sdk
  • not good. Maybe you can explane a concept? if I simply added that field in photon-sdk.js it will work?
  • yes, it's work))
    Maybe someone else will need it
    
    //in Photon-Javascript_SDK.js
    
    //add plugin code
    
    Constants.ParameterCode = {
                    /// <summary>(230) Address of a (Game) server to use.</summary>
                    Address: 230,
                    
                    //... 
    
                    Plugins: 204
                };
    
    //add init field 
    
    function RoomInfo(name) {
                    // standard room properties
                    
                   //...
    
                    this.plugins = [];
                }
    
    //add setter if needed
    
                Room.prototype.setPlugins = function (plugins) {
                    this.plugins = plugins;
                };
    
    //and change two functions
    
    LoadBalancingClient.prototype.fillCreateRoomOptions = function (op, options) {
                    options = options || {};
                    var gp = {};
                    if (options.isVisible !== undefined)
                        gp[LoadBalancing.Constants.GameProperties.IsVisible] = options.isVisible;
                    if (options.isOpen !== undefined)
                        gp[LoadBalancing.Constants.GameProperties.IsOpen] = options.isOpen;
                    if (options.maxPlayers !== undefined)
                        gp[LoadBalancing.Constants.GameProperties.MaxPlayers] = options.maxPlayers;
                    if (options.propsListedInLobby !== undefined)
                        gp[LoadBalancing.Constants.GameProperties.PropsListedInLobby] = options.propsListedInLobby;
                    if (options.customGameProperties !== undefined) {
                        for (var p in options.customGameProperties) {
                            gp[p] = options.customGameProperties[p];
                        }
                    }
                    op.push(LoadBalancing.Constants.ParameterCode.GameProperties, gp);
                    op.push(LoadBalancing.Constants.ParameterCode.CleanupCacheOnLeave, true); //TODO: make this optional?
                    op.push(LoadBalancing.Constants.ParameterCode.Broadcast, true); //TODO: make this optional?
                    if (options.emptyRoomLiveTime !== undefined)
                        op.push(LoadBalancing.Constants.ParameterCode.EmptyRoomTTL, options.emptyRoomLiveTime);
                    if (options.suspendedPlayerLiveTime !== undefined)
                        op.push(LoadBalancing.Constants.ParameterCode.PlayerTTL, options.suspendedPlayerLiveTime);
                    if (options.uniqueUserId !== undefined)
                        op.push(LoadBalancing.Constants.ParameterCode.CheckUserOnJoin, options.uniqueUserId);
                    if (options.lobbyName) {
                        op.push(LoadBalancing.Constants.ParameterCode.LobbyName);
                        op.push(options.lobbyName);
                        if (options.lobbyType != undefined) {
                            op.push(LoadBalancing.Constants.ParameterCode.LobbyType);
                            op.push(options.lobbyType);
                        }
                    }
    
                    if (options.plugins !== undefined)
                        op.push(LoadBalancing.Constants.ParameterCode.Plugins, options.plugins);
                };
    
    LoadBalancingClient.prototype.copyCreateOptionsFromMyRoom = function (options) {
                    options = options || {};
                    //retrieve options from my room
                    options.isVisible = this.currentRoom.isVisible;
                    options.isOpen = this.currentRoom.isOpen;
                    options.maxPlayers = this.currentRoom.maxPlayers;
                    options.customGameProperties = this.currentRoom._customProperties;
                    options.propsListedInLobby = this.currentRoom._propsListedInLobby;
                    options.emptyRoomLiveTime = this.currentRoom.emptyRoomLiveTime;
                    options.suspendedPlayerLiveTime = this.currentRoom.suspendedPlayerLiveTime;
                    options.uniqueUserId = this.currentRoom.uniqueUserId;
    
                    options.plugins = this.currentRoom.plugins;
    
                    return options;
                };
    

    that's all, folks^^
Sign In or Register to comment.