mirror of
https://github.com/jwetzell/osc-go.git
synced 2026-09-10 15:59:28 +00:00
support OSC 1.0 TCP format if SLIP is not enabled
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
@@ -211,6 +212,12 @@ func send(host string, port int32, address string, args []string, types []string
|
|||||||
|
|
||||||
if slip {
|
if slip {
|
||||||
oscMessageBuffer = slipEncode(oscMessageBuffer)
|
oscMessageBuffer = slipEncode(oscMessageBuffer)
|
||||||
|
} else if protocol == "tcp" {
|
||||||
|
// OSC 1.0 prepends a 4 byte size header for non-SLIP TCP messages
|
||||||
|
size := uint32(len(oscMessageBuffer))
|
||||||
|
sizeBytes := make([]byte, 4)
|
||||||
|
binary.BigEndian.PutUint32(sizeBytes, size)
|
||||||
|
oscMessageBuffer = append(sizeBytes, oscMessageBuffer...)
|
||||||
}
|
}
|
||||||
|
|
||||||
netAddress := fmt.Sprintf("%s:%d", host, port)
|
netAddress := fmt.Sprintf("%s:%d", host, port)
|
||||||
|
|||||||
Reference in New Issue
Block a user