Code Monkey home page Code Monkey logo

client-node's People

Contributors

antariano avatar artdude543 avatar chrwhit avatar connor4312 avatar deekyjay avatar dependabot[bot] avatar ethanwaite avatar greenkeeperio-bot avatar jamesbirtles avatar jamydev avatar mattjustmatt avatar milavshah91 avatar misterrick avatar miyu avatar mobius5150 avatar mradder avatar nazar-pc avatar peterdotplus avatar probableprime avatar saadataz avatar sawalkerxbox avatar simonschick avatar thespacearmy avatar turt2live avatar xcausxn 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

Watchers

 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

client-node's Issues

Middle-ware handling of protocol

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.

OAuth Question

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.

Auto Ping Not Checking Connection State

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

Getting User Data

Any chance we could have getUser() back? Was a really handy function to have allowing us easy access to the user data.

Unexpected server response when I'm following the tutorial

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!

Chat Socket Quirks

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.

  1. The 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.
  2. When errors are thrown from the socket the "error" itself seems to not being passed on the 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.

Inconsistent Naming between oauth api and OAuth.ts

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.

[question] spark

how get current spark spent per user or catch when a user spend spark?
i can create a command who spend spark for something?

Defaults

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.

client.game is undefined

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.

TypeError: _.defaultsDeep is not a function

./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

Request is now deprecated

According to the README for request, the request package is now deprecated, and will no longer be updated.

Node.JS (TypeScript) @mixer/client-node Issue.

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?

[TypeScript] Third Party Definitions / Official Support

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.

Error 500 when connect with mixer chat

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)

semantic-release

Automatic change logs and less management is a win. lets do it

No handle for ws socket code 1001

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

User-specified logger

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.

Requests - No User Agent

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

Method Whisper

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"]}');

Cannot find module 'beam-client-node/lib/ws'

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)

`<ChatSocket>.auth()` should be handled internally

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?

[TypeScript] Rewrite / Port

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.

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.