Giter Club home page Giter Club logo

obs-websocket-js's People

Contributors

artdevgame avatar astral-arsonist avatar brian-gates avatar dangmai avatar duncte123 avatar faultyserver avatar greenkeeper[bot] avatar haganbmj avatar hoishin avatar i-false avatar jwulf avatar lebaston100 avatar mint-dewit avatar niek avatar panger95 avatar richienb avatar rodrigograca31 avatar t2t2 avatar tt2468 avatar zoton2 avatar

Stargazers

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

obs-websocket-js's Issues

[API] Strengthen Address Parsing

Is this a request for a new feature or a bug report?
Feature, Potential Bug

General Description:
Strengthen address parsing.

  • Parse user input address.
  • Correct syntax
  • Determine if defaulting a port is relevant/required when the user could be routing through 8080 or something silly. Might be better to just have consumers handle input validation?

Relevant Ghetto Code Location -- Socket.js#connect()
It's also probably correct to check if the user submit something prefixed with ws:// already and relocate this.

Disconnect function

Something like a disconnect function from the websocket would be helpful to correctly close a connection.
Maybe this will prevent OBS from crashing when trying to connect multiple times (just an idea).

[API] Rejects when no Socket Connection Exists

Is this a request for a new feature or a bug report?
Bug

General Description:
If there's no socket connection sending any request produces an error, which apparently isn't used as a reject.

obs.getCurrentScene().then(data => { console.log('success'); }).catch(err => { console.log(err); });
> WebSocket is already in CLOSING or CLOSED state.
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

To fix this, really all that's needed is a quick check to see whether the socket is connected, and issuing a reject if not.
https://github.com/haganbmj/obs-websocket-js/blob/master/lib/OBSWebSocket.js

SetTextGDIPlusProperties - invalid request type

Description:

SetTextGDIPlusProperties does not work, and fails with 'invalid request type' on attemping to use it.
The error occurs with or without passed params.

Reproduction:

obs.setTextGDIPlusProperties({})
	.then((x) => {
	    console.log('Success', x)
	})
	.catch((x) => {
	    console.log('Error', x)
	})
Error { error: 'invalid request type',
  'message-id': '2',
  status: 'error',
  messageId: '2' }

Versions:

  • obs-websocket-js version: 0.7.0
  • obs-websocket plugin version: 4.0.0
  • obs-studio version: 19.0.3

[API] Revise Project Structure

General Description:

  • index.js as an entry point serves no purpose currently. Move the lib/OBSWebSocket.js into it, or something? Maybe move index.js back out to the root directory.
  • Rename/Rearrange lib files to be more descriptive
  • Figure out where the connect/authenticate methods should reside.
  • Figure out what the purpose having a lib/Core.js is when I could just put that inside something else.
  • Figure out bower publishing requirements.
  • etc.

[Style] Consider using ESlint instead of jshint

ESlint is more common these days and has more active development. In addition, there are several widely used eslint configs, and you can easily add your own per-project preferences on top of these configs.

Let me know if any of these seem good to you, and I'll open a PR to implement it.

async connect Unexpected identifier

This is a Bug report I am trying to run obs-websocket-js in my node.js app.
when the script tries to connect I get following errormessage. Any help would be appreciated.

C:\project\scheduler-windows\node_modules\obs-websocket-js\lib\Socket.js:36
async connect(args = {}, callback) {
^^^^^^^

SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (C:\project\scheduler-windows\node_modules\obs-websocket-js\lib\OBSWebSocket.js:1:78)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)<!--

Steps to Reproduce the Issue (if applicable):

  1. Install all Tools copy code below to a js file and start node.js
  2. ...
  3. ...

Versions Used (if applicable):

  • obs-websocket-js version: 0.7.0
  • obs-websocket plugin version: 4.0
  • obs-studio version: 20.0.1

This is my Node.js code and I want to connect to localhost:4444

...
`const OBSWebSocket = require('obs-websocket-js');
const obs = new OBSWebSocket();

// Declare some events to listen for.
obs.onConnectionOpened(() => {
console.log('Connection Opened');

// Send some requests.
obs.getSceneList({}, (err, data) => {
console.log("Using callbacks:", err, data);
});

obs.getSceneList().then(data => {
console.log("Using promises:", data);
});
});

obs.onSwitchScenes(data => {
console.log(data);
});

obs.connect();`

obs.connect SyntaxError: Unexpected identifier

My Code:

const OBSWebSocket = require('obs-websocket-js'); const obs = new OBSWebSocket(); obs.connect({ address: 'localhost:4444'});
Error:

C:\Users\compt\Desktop\OBS\node_modules\obs-websocket-js\lib\Socket.js:36
async connect(args = {}, callback) {
^^^^^^^
SyntaxError: Unexpected identifier
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:511:25)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:456:32)
at tryModuleLoad (module.js:415:12)
at Function.Module._load (module.js:407:3)
at Module.require (module.js:466:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\compt\Desktop\OBS\node_modules\obs-websocket-js\lib\OBSWebSocket.js:1:78)
at Module._compile (module.js:541:32)

[API] Use .once instead of manually handling parameter callbacks

Is this a request for a new feature or a bug report?
Enhancement

General Description:
Just a thought. Rather than manually executing callbacks, should be able to just assign them a .once and let EventEmitter handle it.
In .send there's already a binding for the internal message id, which both executes the callback and resolves the promise.
By binding two .onces, one for the callback and one for the Promise should be able to clean up a number of places where some unnecessary callback wrapping is done.

The only reason this api accepts callbacks as a parameter is to support some older implementations that used that syntax - not entirely opposed to just eliminating that and forcing the use of promises as the only means of interaction with the api. There's a reason this still doesn't have a 1.0.0 release.

Issue and Request

Hi, my issue is, for some reason source bounds are 0, I can't work out if this is a obs-websocket-js or a obs-websocket issue

image

my request is for more events/functions, for example, I want to be able to change a sources position and dimensions when, for example, I use jQueryUI draggable() and resize() to change them on my webUI

image The WebUI so far, this is for a friend to be able to control his OBS when he's at conventions, etc...

I also posted this over at obs-websocket

scene names with "special" characters don't work

Scene names in OBS with characters like "Ä", "Ü", "Ö", "ß" (pretty important for germans) don't work.
There's an error when trying to send the scene name to OBS (needed for 'setCurrentScene').

[API] Expose registerEvent and registerRequest methods

Is this a request for a new feature or a bug report?

Enhancement

Description:

Expose unique addEvent/registerRequest (or whatever name works) methods so that user's can bind their own custom plugin handlers should they need. In case they prefer the .onEventName and .requestName syntax.
Currently this is done internally in lib/methodBinding, it'll need to be split out a bit and exposed.

[API] Expose 'connected' and 'authenticated' status

Is this a request for a new feature or a bug report?
Enhancement

General Description:

  • Expand the ._connected variable to either a combined state object or just add an ._authenticated variable.
  • Consider dropped the underscore as these are intended to be publicly visible.

[CI] Update Travis Scripts to Ensure updated Distributable

General Description:
Had this sort of working and I still have the scripts offline, basically my ideal functionality would be...

  • Semver the commit based on the commit message, automatically apply versioning.
  • Webpack and JSDoc the project. Push updated project + dist to gh-pages.
  • Publish a prerelease build or a release to npm
  • Allow optionally publishing a release instead based on commit message

[Protocol] Rewrite with Versioning obs-websocket in Mind

Type of Issue: Enhancement

General Description:

  • Working with the expectation that Palakis/obs-websocket will be pushing new endpoints and likely changing old endpoints, it makes sense to implement some sort of version management now.
  • Proposed method will be to maintain an API definition in the file, with each release of obs-websocket explicitly defined by RequestType, params, and response object.
  • Add error handles, likely with Throw since not every request is required to pass a resolution callback/Promise-style argument... Though that would probably be better/more consistent to enforce that now.

[Docs] Determine if Generated Docs are Still Relevant

General Description:
Need to figure out JSDocs in Node's class structure.

I'm not sure there's much point now that this is just straight consuming exactly what the obs-websocket plugin puts out. Using the docs there should be sufficient past a couple guidelines here.

Fix onAuthenticationFailed emitter

Is this a request for a new feature or a bug report?

Bug

Description:

Not possible to emit onAuthenticationFailed. Gets swallowed up as a general connection failure.

Versions Used (if applicable):

  • obs-websocket-js version: 0.6.1
  • obs-websocket plugin version: n/a
  • obs-studio version: n/a

Extra Information / Code Samples / etc:

Sample unit test demonstrating this failure is in test/auth.spec.js

not supported outside strict mode

Is this a request for a new feature or a bug report?

bug

Description:

importing obswebsocket throws the error:

C:\Users\werel\node_modules\obs-websocket-js\lib\OBSWebSocket.js:6
let requestCounter = 0;
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet sup
ported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\werel\node_modules\obs-websocket-js\index.js
:1:80)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

Steps to Reproduce the Issue (if applicable):

Versions Used (if applicable):

all newest as of 14th august 2017

Extra Information / Code Samples / etc:

None

[API] Standardize internal emits

Is this a request for a new feature or a bug report?
Enhancement

General Description:
Right now there are a bunch of individual calls emits using obs:internal:event or obs:internal:request or whatever.

  • Consider either standardizing the string name for this in some sort of Enum or wrapping these in their own function so that there isn't any room for a typo to pop up.

[CI] Update to npm@5

Had issues (locally and in travis) with npm5 and package-locks.
The install commands seems to function differently and getting both dev and non-dev dependencies installed is a pain in the ass.

Going to wait until some of the bugs get worked out.

setSourceVisbility not working

Using 'setSourceVisbility' always gives me the error [OBSWebSocket] Error: invalid request type.

Example code:
ws.setSourceVisbility("Gamerecording", false);

Am I doing it wrong or is it a bug?

Syntax Error unexpected identifier

Syntax not clear from documenation

Description:

When trying to send a command to obs websocket. I get following error. I think my syntax is somehow not ok. But I am not too much into Promises right now. Can u help me? Also it would be nice if u could bring some light on the args that are supported. How does a typical args look like?

Steps to Reproduce the Issue (if applicable):

  1. Install packages and copy code below into a function and execute it.
  2. ...
  3. ...

Versions Used (if applicable):

  • obs-websocket-js version: 0.7.0
  • obs-websocket plugin version: 4.0.0
  • obs-studio version: 20.0.1
  • node.js 8.5

Extra Information / Code Samples / etc:

`C:\project\startstop\modules\obs.js:36
obs.send('StartRecording', {args}, callback(err, data)) returns Promise
^^^^^^^

SyntaxError: Unexpected identifier
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:537:28)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object. (C:\project\startstop\modules\socketio.js:3:11)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)`

[API] Convert AuthHashing from a Class to a Function

Is this a request for a new feature or a bug report?
Enhancement

General Description:
What's the point of instantiating an AuthHashing object when it's only used for one function and currently the only entry point to Authenticate retrieves the salt/challenge each time meaning that it doesn't need to be stored anywhere.

Support ".on(" style event emissions.

Type of Issue:

  • Suggestion

General Description:

  • Add support for .on("eventName", callback) style event emissions.

Any Additional Information:

Currently, I'm just using this intermediate class:

const EventEmitter = require('events');
const mixin = require('mixin');
const OBSWebSocket = require('obs-websocket-js').OBSWebSocket;

const allEvents = [
		'onConnectionOpened',
		'onConnectionClosed',
		'onConnectionFailed',
		'onAuthenticationSuccess',
		'onAuthenticationFailure',
		'onSceneSwitch',
		'onSceneListChanged',
		'onStreamStarting',
		'onStreamStarted',
		'onStreamStopping',
		'onStreamStopped',
		'onRecordingStarting',
		'onRecordingStarted',
		'onRecordingStopping',
		'onRecordingStopped',
		'onStreamStatus',
		'onExit'
	];

class OBSWebSocketEE extends mixin(OBSWebSocket, EventEmitter) {
	constructor() {
		super();
		allEvents.forEach(n => {
			// Alias of the event name without the "on" and lowerCamelCased.
			let eventName = n.slice(2);
			eventName = eventName[0].toLowerCase() + eventName.slice(1);
			this[n] = (...args) => {
					this.emit(n, ...args);
					this.emit(eventName, ...args);
				};
		});
	}
}

module.exports = OBSWebSocketEE;

OBSWebSocket is not a constructor error

Type of Issue:

  • e.g. Bug / Enhancement / Suggestion / Development Trouble
    bug

General Description:

  • Details.
    OBSWebSocket is not a constructor error when using code.

[CI] Generate available requests/events from plugin page

Assuming my PR for generated docs goes through in obs-websocket then it would be easiest to generate the list of available requests/events based on those docs.
Unsure if I'd want this to be some scheduled CI build that pushes back to master or something else instead.

[API] Binding multiple events results in duplicate callbacks

Is this a request for a new feature or a bug report?
Bug

General Description:

  • Looks like if you were to assign multiple callbacks to the same event you'd end up with some excess execution.
  • There's no need to store and iterate the event callbacks if you just map each individual callback to it's own .on emitter.

Proposed:

  • Strip out all the stored callback tracking, simply act as a (mostly pointless) wrapper for event emitter the same way all the Send methods are wrappers of .send.
  • Should probably keep the check for whether or not the callback is a function, might consider throwing an exception if it isn't, though.

Extra Information / Code Samples / etc:
https://github.com/haganbmj/obs-websocket-js/blob/master/lib/methodBinding.js#L43

onSceneListChanged not working

I don't know if I'm doing it wrong but using the callback onSceneListChanged doesn't work for me.
The response I get from this function is always null.

For example this gives me null:
ws.onSceneListChanged = function(response) { console.log(response); };

I got no problem with other functions like 'onSceneSwitch' for example.

[Log] Silence logging by default

Currently, obs-websocket-js is quite noisy in the console with its log messages. It's generally standard for libraries to be "silent" -- that is: to only print output to the console if the consumer of that library has explicitly requested this behavior via some type of debug flag, configuration parameter, or environment variable.

@haganbmj If it's okay with you, I'll open a PR that silences all log statements by default unless some debug flag has been set to true.

start / stop stream / record error

Hi haganbmj,

at first: Thank you for this project! My first steps on controlling the obs websocket were quite positive. There is one thing, that doesn't work for me as expected:

I get an error on sending a 'StartStreaming', 'StopStreaming', 'StartRecording' or 'StopRecording' request:

[OBSWebSocket] Error: invalid request type

I wrote the function myself based on the already existing and working 'StartStopStreaming' - request in obs-websocket.js:

OBSWebSocket.prototype.startStreaming = function() { this._sendRequest('StartStreaming'); };

Here is my system:

  • obs-websocket-js v0.3.3
  • obs-websocket plugin v4.0.0
  • obs v18.0.1

I worked with the official websocket plugin protocol and couldn't see any complications concerning the RequestHandler.

Do you know what causes this error and how to solve it?

Many thanks!

Offering to help as contributor

Hi @haganbmj!

I noticed you said that you don't have as much time as you'd like to dedicate to the obs-websocket-js project. I'd be happy to help with some of the code work if you could clearly lay out a list of tasks on the project board. This would help me know where to start and let me work the fastest. Let me know if this organizational work is something you have time for.

Thanks,
Alex

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.