mixer / client-node Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
If specified, the library should output appropriate log messages using the specified instance. The logger is required to conform to the same interface the native console
object does.
As the websocket class handles the pinging to the chat server. It should be checking if the socket is open before trying to ping. Otherwise if the socket is closed ws
will throw an error about is being closed. Which with promises you can handle this; But as the class will reject or "kill" the chat connection if it does not get a pingback (within time) so it can be reconnected. I think the class should check and if closed then run the code for the safe closing etc..
According to the README for request, the request package is now deprecated, and will no longer be updated.
./example/joinChat.js
/beam-client-node/lib/client.js:109
var req = _.defaultsDeep(data || {}, _.extend(
^
TypeError: _.defaultsDeep is not a function
at Client.request (/beam-client-node/lib/client.js:109:17)
at PasswordProvider.attempt (/beam-client-node/lib/providers/password.js:29:24)
at Object.<anonymous> (/beam-client-node/example/joinChat.js:10:4)
at Module._compile (module.js:541:32)
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 Function.Module.runMain (module.js:575:10)
at startup (node.js:159:18)
at node.js:444:3
Would there be any objects to me creating a PR (When it's completed) of a full TypeScript version of this repo? I'm planning on updating somethings along with converting the code over. I also intend to adding live loading support along with support for the planned socket changes. To get the module ready for that.
If not I could create a fork for people wanting a pure TS module and will post changes here to that. But I'd rather the latter for easier updating / managing / support.
I'd like to use this module more for projects but it's lacking areas such as live loading support along with custom integrations. I'm creating this issue before doing anything to see what your guys thoughts are on this and/or if you already have a planned re-write of this module anytime soon. So I don't end up creating something in which you already have on the sprint. The same would apply for the node interactive repo in terms of re-writing it.
The property naming with OAuth.ts for the OAuthProvider constructor's options.tokens
is inconsistent with what the OAuth api returns equating to the program having to do some middle-man-mutating of the api's response before calling the OAuth constructor.
API Uses | OAuth.ts Uses |
---|---|
client_id | clientId |
client_secret | secret |
access_token | access |
refresh_token | refresh |
expires_in | expires* |
*) This is fine as the two names refer to two different pieces of data (API returns a number, OAuth.ts expects a ISO date string)
This is predominately only an issue with the setTokens()
function. Since its called from the constructor it inhibits the user/app from passing an oauth api response directly into the constructor.
This sample code for NodeJS:
client.use(new Mixer.OAuthProvider(client, { tokens: { access: '{{ token here }}', expires: Date.now() + (365 * 24 * 60 * 60 * 1000) }, }));
Is outputting the below error.
Argument of type '{ tokens: { access: string; expires: number; }; }' is not assignable to parameter of type 'IOAuthProviderOptions'. Property 'clientId' is missing in type '{ tokens: { access: string; expires: number; }; }' but required in type 'IOAuthProviderOptions'.ts(2345) OAuth.d.ts(14, 5): 'clientId' is declared here.
Am I doing something wrong or is there a issue with the type declarations for TypeScript?
I'm currently using your API to test out some OAuth -
/oauth/shortcode/check/{handle}
I'm using the following api endpoint that is referenced in the reference section of your documentation and it says that I should be receiving a code in the response but all I'm getting is a url with this endpoint and the code to get an accessToken in that url -
I tried adding my clientId to the header as well as the clientSecret but I'm running in circles and haven't been having the best time reading the documentation.
Am I supposed to get the code through that url somehow? Thanks.
The provided chat wrapper has some issues I've noticed since switching my bot to using it full time for connecting to Beam chats. Here are the two main things I've noticed so far. From testing / playing around with the code.
boot()
method does not check if it already has a socket active (apart from checking if the var is set) and then registers the event listeners on that socket causing duplicated events to occur. I'd think it might be better to return out of the method if we already have an active socket or return the current instance again. So more events are not registered.emit("error".....
which is odd as it should be from reviewing the code and from local testing the error short message and/or the code should be thrown with the error so developers can debug the error. But the socket does not seem to give you any information on regards to what the error was/is. The only one I've seen is 502
errors and that's it.I've been playing around with the idea of the client having some more emits when reconnecting
or debug internal events so it helps with debugging. The reconnection would be nice so we can do a timeout for if the client is going to auto reconnect and if it does not then use our own reconnection code as an example. A nice little addition which could have some benefits in the long run.
how get current spark spent per user or catch when a user spend spark?
i can create a command who spend spark for something?
It seems you don't have this package published yet..
npm ERR! 404 Not Found: @mixer/client-node
https://www.npmjs.com/package/@mixer/client-node
Should I be using beam-client-node
instead?
In the last few days, I have this errors on my server
Error: unexpected server response (500)
at ClientRequest._req.on (/home/ubuntu/boombot-server/node_modules/ws/lib/WebSocket.js:642:26)
**at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:474:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
at TLSSocket.socketOnData (_http_client.js:363:20)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at TLSSocket.Readable.push (_stream_readable.js:134:10)
Sometimes I even have this error:
Error: unexpected server response (525)
at ClientRequest._req.on (/home/ubuntu/boombot-server/node_modules/ws/lib/WebSocket.js:642:26)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:474:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
at TLSSocket.socketOnData (_http_client.js:363:20)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
Should have a tiny migration guide too.
How do you go about sending a whisper? The only method i can seem to use is msg
socket.call('msg', [
@${data.user_name} Hello]);
I tried
socket.call('whisper', [
@Testy1234t Hello]);
and
socket.call('{"type":"method","method":"whisper","arguments":["Testy1234t","test"]}');
Along with the other purposed changes to make the client less cumbersome to use, authorization should be spooled internally.
currently, new Mixer.ChatService(client).join(channelId)
retrieves the auth information translating to the client already having all necessary data to authorize, so why is it up to the project to queue authorization?
I am trying to update to 1.x.x from 0.13.0, when I try to run there is this error "cannot find module 'beam-client-node/lib/ws'
I believe I had ws 1.0.0 installed with 0.13.0 (since 0.13.0 required ws 1.0.0)
Heyo,
I've been working on creating a TypeScript definition for this module (and the interactive one soon) to help with people using this module with TypeScript. For this I'd like to publish it to the registry and such so it's easily downloadable for users. You can find information about the registry here along with how the contribution system works. I do intend to keep the Typings up to date as much as I can along with possible support from the community.
I've come to here to ask for permission to host and create the Typings for this module and beam-interactive-node
this could either be official or third party depending on how you guys want to handle this.
If you need more information about this or have questions please do ask.
let client = new Mixer.Client(new Mixer.DefaultRequestRunner())
No one is going to write their own request running, let's just default it. If its not defined make one.
I've mentioned this before but logging it here formally :).
var Beam = require('beam-client-node');
var Tetris = require('beam-interactive-node');
var rjs = require('robotjs');
var stream = 1234;
var username = 'connor';
var password = 'password';
var beam = new Beam();
beam.use('password', {
username: username,
password: password
}).attempt().then(function () {
return beam.game.join(stream); //FAILS HERE
}).then(function (details) {
var robot = new Tetris.Robot(details);
robot.handshake();
robot.on('report', function (report) {
var mouse = robot.getMousePos();
rjs.moveMouse(
Math.round(mouse.x + 300 * report.joystick[0].mean),
Math.round(mouse.y + 300 * report.joystick[1].mean)
);
});
});
Getting around this using manual requesting but you might want to fix it up at some point.
Automatic change logs and less management is a win. lets do it
In theory this module should be sending a user agent with any requests. As CloudFlare can / will stop requests with no agents. This would prevent issues like it from happening. I would PR the fix but not sure on what Agent you would like to use. I.E. Custom named for tracking / debugging etc...
Any chance we could have getUser() back? Was a really handy function to have allowing us easy access to the user data.
const chat = new Mixer.Socket(ws, endpoints).boot();
Is a mess
Hi,
I've tried to follow the node tutorial here:
https://dev.mixer.com/guides/chat/chatbot.html
and I'm getting this as a response:
Socket error
Error: unexpected server response (400)
at ClientRequest.response (C:\node_modules\ws\lib\WebSocket.js:719:15)
at Object.onceWrapper (events.js:277:13)
at ClientRequest.emit (events.js:189:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:556:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
at TLSSocket.socketOnData (_http_client.js:442:20)
at TLSSocket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
at readableAddChunk (_stream_readable.js:265:11)
at TLSSocket.Readable.push (_stream_readable.js:220:10)
This is my code (minus the token)
https://gist.github.com/lee-brown/a2332fd8861c156a5987c1b22667eae8
Is this an issue with the node client/api or is it a problem with my code? Any help would be greatly appreciated thank you!
Certain applications of the library need to be able to touch the underlying protocol handling. Essentially, there should/needs to be hooks exposed to override or apply in series with internal handling of the protocol so that projects that use this library can apply their own custom handling,
Some use-case examples:
Ability to hook auth
so we can debug connection issues as well as stop further processing(to prevent anonymous logins)
Ability to hook the ChatMessage handling. For my use, I want to mutate the data received before the event is emitted, as well as correlate messages sent from the client with the events that arise from sending such.
It is possible for an application using ws lib provided beam node api to receive ws code 1001. Upon receiving this code, the application is supposed to reconnect to the ws. Beam api however, goes ahead and crashes the whole application instead. Response that is found in the log is: Error: No handler for reply ID.
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.