Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events of json type don't have their Content-Type header set #15

Open
regner opened this issue Jun 7, 2018 · 0 comments
Open

events of json type don't have their Content-Type header set #15

regner opened this issue Jun 7, 2018 · 0 comments

Comments

@regner
Copy link

regner commented Jun 7, 2018

Sample code:

// Setup, connection handling, etc.

b := bytes.NewBufferString("event json DTMF\n")
b.WriteTo(conn)

// Some other code and then this runs in a goroutine for us

for {
    msg, err := conn.ReadMessage()

    // For JSON events this ends up being ""
    msgType := msg.GetHeader("Content-Type")

    switch msgType {
    case "text/disconnect-notice":
        done <- true
    case "text/event-plain":
        // assuming "event plain DTMF" is sent instead of JSON this will trigger
    case "text/event-json":
        // This will never trigger
    }

    //This is my current hack
    if eventName, ok := msg.Headers["Event-Name"]; ok {
        switch eventName {
        case "DTMF":
            logger.Errorf("DTMF: %s", msg.Headers["DTMF-Digit"])
        }
    }
}

Our current version of gesl:
revision = "1cd1251c682b6645e93bdc58ba48de5ed75fbd48"
version = "1.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant