Code Monkey home page Code Monkey logo

Comments (13)

nuclearace avatar nuclearace commented on May 18, 2024

@hanishabsigh can you provide a message that fails to get parsed. You can uncomment https://github.com/socketio/socket.io-client-swift/blob/master/SwiftIO/SocketEngine.swift#L409 to see messages before they get sent to the socket.io-client parser.

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

I'm actually finding a few problems with regex. Mostly due to the differences between NSString and String.

from socket.io-client-swift.

hanishabsigh avatar hanishabsigh commented on May 18, 2024

My object that fails is very large, here is an example I was able to track down:

The following fails:

"42[\"auto\",{\"message_of_the_date\":\"line one\nline two\"}]"

The following succeeds:

"42[\"auto\",{\"message_of_the_date\":\"line one line two\"}]"

The line break in the message of the day causes the parsing of the groups to break.

from socket.io-client-swift.

hanishabsigh avatar hanishabsigh commented on May 18, 2024

@nuclearace I just noticed you made some parsing changes, this was tested prior to those changes, thanks

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

@hanishabsigh It seems to work for me on the latest. Please note #13 though. Since it can cause the regex to fail sometimes. Which is why I changed some things.

from socket.io-client-swift.

hanishabsigh avatar hanishabsigh commented on May 18, 2024

@nuclearace This still isn't working for me, incoming messages can't even get passed the following line:

let messageGroups = stringMessage["(\\d*)\\/?(\\w*)?,?(\\d*)?\\[\"(.*?)\",?(.*?)?\\]$"].groups()

Replacing line 224 with the following worked:

let messageGroups = stringMessage["(\\d*)\\/?(\\w*)?,?(\\d*)?\\[\"(.*?)\",?(.*?)?\\]$", NSRegularExpressionOptions.DotMatchesLineSeparators].groups()

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

@hanishabsigh try after 44e2781

from socket.io-client-swift.

hanishabsigh avatar hanishabsigh commented on May 18, 2024

@nuclearace Checking against the latest commit isn't working, something about the changes in SwiftRegex. So far from what I can tell regex.firstMatchInString in the groups method isn't returning anything. Still investigating. Thanks

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

This client is able to get this for me:

socket.emit("jsonTest", {foo: "string\ntest test"})

from socket.io-client-swift.

hanishabsigh avatar hanishabsigh commented on May 18, 2024

Ok, fixed it by changing the following:

final var targetRange: NSRange {
    return NSRange(location: 0,length: countElements(target))
}

To this:

final var targetRange: NSRange {
    return NSRange(location: 0,length: target.utf16Count)
}

I think the error I was experiencing was happening because my json had variable-width Unicode characters. Found someone having the same issues with swift on StackOverflow: http://stackoverflow.com/questions/25882503/how-can-i-use-nsregularexpression-on-swift-strings-with-variable-width-unicode-c

from socket.io-client-swift.

nuclearace avatar nuclearace commented on May 18, 2024

@hanishabsigh so does c67e7a3 fix it

from socket.io-client-swift.

hanishabsigh avatar hanishabsigh commented on May 18, 2024

@nuclearace Yes, that commit fixes it, thanks.

from socket.io-client-swift.

Katafalkas avatar Katafalkas commented on May 18, 2024

screen shot 2015-03-19 at 13 12 34
screen shot 2015-03-19 at 13 13 00

From Xcode 6.3 beta 3 release notes:
>`utf16Count` is removed from String. Instead use count on the UTF16 view of the String. (17627758)

@hanishabsigh @nuclearace

from socket.io-client-swift.

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.