Coder Social home page Coder Social logo

Comments (5)

ahyatt avatar ahyatt commented on July 18, 2024

I can reproduce this. I think I may have just fixed the client behavior, not the server behavior. This looks a bit tricky, but I'll take a look and see if I can fix it in the next week.

from emacs-websocket.

alpha22jp avatar alpha22jp commented on July 18, 2024

Hi @ahyatt,

I found the cause. It's actually a problem of test code. The string server received is UTF-8 byte sequence, so it has to be converted to unibyte format before we pass it to websocket-send-text function.

After I modified test code as below, the test passed successfully.

--- old.el        2016-10-22 10:44:21.210792558 +0900
+++ new.el        2016-10-22 10:43:56.826793474 +0900
@@ -5,7 +5,7 @@
                     :on-message (lambda (ws frame)
                                   (message "Server received text!")
                                   (websocket-send-text ws
-                                                       (websocket-frame-payload frame)))
+                                                       (decode-coding-string (string-make-unibyte (websocket-frame-payload frame)) 'utf-8)))
                     :on-open (lambda (_websocket) "Client connection opened!")
                     :on-close (lambda (_websocket)
                                 (setq wstest-closed t)))))

from emacs-websocket.

ahyatt avatar ahyatt commented on July 18, 2024

That's interesting that you solved it this way.... I looked at this yesterday and traced this down to the websocket-mask function, which incorrectly makes a string of bytes in such a way that it is interpreted as a multibyte string of what are actually unibytes. So I think working around this problem in this way may work, but shouldn't be necessary. I'll take a look tomorrow about the best way to fix it - maybe just wrapping that function in string-make-unibyte would be best.

from emacs-websocket.

ahyatt avatar ahyatt commented on July 18, 2024

Should be fixed in f7d3fb5, if you use the handy new function websocket-frame-text, please re-open if not.

from emacs-websocket.

ahyatt avatar ahyatt commented on July 18, 2024

That's interesting that you solved it this way.... I looked at this
yesterday and traced this down to the websocket-mask function, which
incorrectly makes a string of bytes in such a way that it is interpreted as
a multibyte string of what are actually unibytes. So I think working
around this problem in this way may work, but shouldn't be necessary. I'll
take a look tomorrow about the best way to fix it.

On Fri, Oct 21, 2016 at 9:53 PM alpha22jp [email protected] wrote:

Hi @ahyatt https://github.com/ahyatt,

I found the cause. It's actually a problem of test code. The string server
received is UTF-8 byte sequence, so it has to be converted to unibyte
format before we pass it to websocket-send-text function.

After I modified test code as below, the test passed successfully.

--- old.el 2016-10-22 10:44:21.210792558 +0900+++ new.el 2016-10-22 10:43:56.826793474 +0900@@ -5,7 +5,7 @@

                 :on-message (lambda (ws frame)
                               (message "Server received text!")
                               (websocket-send-text ws
  •                                                   (websocket-frame-payload frame)))+                                                       (decode-coding-string (string-make-unibyte (websocket-frame-payload frame)) 'utf-8)))
    
    
                 :on-open (lambda (_websocket) "Client connection opened!")
                 :on-close (lambda (_websocket)
                             (setq wstest-closed t)))))
    

β€”
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#45 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABP5LQpSYcnx1yjNLJw3lq5MWYZNRCsks5q2WyZgaJpZM4KaYFg
.

from emacs-websocket.

Related Issues (20)

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.