Giter VIP home page Giter VIP logo

pollnet's People

Contributors

dependabot[bot] avatar probable-basilisk avatar

Stargazers

 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

Forkers

hotarublaze

pollnet's Issues

WebSockets server socket closing itself?

I'm having some issues trying to use websockets with pollnet. So here I've got a simple echo server:

local pollnet = require("pollnet") 

local sock = pollnet.listen_ws("ws://127.0.0.1:12347")

while true do
  if not sock then return end

  local happy, msg = sock:poll()
  
  if not happy then
    print("closing sock")
    sock:close() -- good form to avoid keeping listen_sockets open
    sock = nil
    os.exit()
  else
    print("happy")
  end

  if msg then
    sock:send(msg)
  end
end

But this is what it prints:

$ ./luajit.exe wsserv.lua
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
happy
closing sock

Status changes from openint to open then to opening again

Hi!

I'm using the latest Pollnet 1.0.1 with liajit and I observe some strange behavior. The code is

local pollnet = require("pollnet")
local url = "wss://irc-ws.chat.twitch.tv:443"
local sock = pollnet.open_ws(url)
local sock_status = nil
repeat
    local happy, msg = sock:poll()
    local new_status = sock:status()
    print("*** " .. new_status)
    if new_status ~= sock_status then
        print(msg)
    end
    
    sock_status = new_status
    pollnet.sleep_ms(300)
until not happy

And I get the following output (note the status changes opening -> open -> opening):

*** opening
nil
*** opening
*** opening
*** open
nil
*** opening
nil
*** opening
*** opening
*** opening

This changes a bit if I send PASS and NICK commands to twitch when the status becomes open:

local pollnet = require("pollnet")
local url = "wss://irc-ws.chat.twitch.tv:443"
local sock = pollnet.open_ws(url)
local sock_status = nil
repeat
    local happy, msg = sock:poll()
    local new_status = sock:status()
    print("*** " .. new_status)
    if new_status ~= sock_status then
        print(msg)
        if sock_status == "open" then
            sock:send("PASS nopass")
            local anon_user_name = "justinfan" .. math.random(1, 100000)
            sock:send("NICK " .. anon_user_name)
        end
    end
    
    sock_status = new_status
    pollnet.sleep_ms(300)
until not happy

The output:

*** opening
nil
*** opening
*** opening
*** open
nil
*** opening
nil
*** opening
*** open
:tmi.twitch.tv 001 justinfan79421 :Welcome, GLHF!
:tmi.twitch.tv 002 justinfan79421 :Your host is tmi.twitch.tv
:tmi.twitch.tv 003 justinfan79421 :This server is rather new
:tmi.twitch.tv 004 justinfan79421 :-
:tmi.twitch.tv 375 justinfan79421 :-
:tmi.twitch.tv 372 justinfan79421 :You are in a maze of twisty passages, all alike.
:tmi.twitch.tv 376 justinfan79421 :>

*** open
*** open

The socket ends up in the open state but it still returns to opening for some time.
I'm using LuaJIT built from the master branch with MSYS/MinGW64 and pollnet is from the latest 1.0.1 release zip 64-bit Windows.

Can't seem to get a status code from an http GET

Hello,

I have followed the examples which state that for example an http get should contain 2 messages, one being the status code and the other being the body.

I was trying to get a file from github but the body arrives as the first message. I have tried to wait until more messages arrive as well to see if the order is not flipped but on the second poll call the socket is already closed. Tested even without any manual socket closing and just looping poll on each game tick to see what it receives and the only thing I ever receive is just the body.

Am I missing something or is there currently no way to get an http status code ?

Thanks in advance.

how to use pollnet.dll in vc++ and excel vba create websocket server/CLIENT

how to use pollnet.dll in vc++ and excel vba create websocket server/CLIENT
DO YOU HAVE A sample,thank you

Private Declare Function pollnet_listen_ws Lib "pollnet.dll" () As Long
Private Declare Function pollnet_open_ws Lib "pollnet.dll" () As Long
Private Declare Function pollnet_close Lib "pollnet.dll" () As Long

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.