Trennung von Send- und Receive-Methods war völlig unsinnig -> vereinheitlicht

master
Klaus Wendel 8 months ago
parent d52fd43f12
commit db8e9f74d5

@ -20,12 +20,17 @@ type CarrierJson struct {
type WsCommunicationMethod string
const (
SendTextMethod WsCommunicationMethod = "sendtext"
SendBinaryMethod WsCommunicationMethod = "sendbinary"
SendJsonMethod WsCommunicationMethod = "sendjson"
ReceiveTextMethod WsCommunicationMethod = "receivetext"
ReceiveBinaryMethod WsCommunicationMethod = "receivebinary"
ReceiveJsonMethod WsCommunicationMethod = "receivejson"
/*
SendTextMethod WsCommunicationMethod = "text"
SendBinaryMethod WsCommunicationMethod = "binary"
SendJsonMethod WsCommunicationMethod = "json"
ReceiveTextMethod WsCommunicationMethod = "text"
ReceiveBinaryMethod WsCommunicationMethod = "binary"
ReceiveJsonMethod WsCommunicationMethod = "json"
*/
TextMethod WsCommunicationMethod = "txt"
BinaryMethod WsCommunicationMethod = "binary"
JsonMethod WsCommunicationMethod = "json"
)
type GosmContainer struct {
@ -85,13 +90,13 @@ func (r *GosmContainer) GetBuffer() []byte {
func (r *GosmContainer) WsContainerSend(method WsCommunicationMethod, conn *websocket.Conn, ctx context.Context) (err error, hisresponse interface{}) {
switch method {
case SendJsonMethod:
case JsonMethod:
err, hisresponse = WsjsonSend(ctx, conn, (*r).CarrierJson)
//(*r).CarrierJson = tmpreceiveval.(CarrierJson) //Überschreibe alten Wert?
case SendTextMethod:
case TextMethod:
//err, (*r).CarrierBuffer = WsSend(ctx, conn, (*r).CarrierBuffer, websocket.MessageText)
err, hisresponse = WsSend(ctx, conn, (*r).CarrierBuffer, websocket.MessageText)
case SendBinaryMethod:
case BinaryMethod:
//err, (*r).CarrierBuffer = WsSend(ctx, conn, (*r).CarrierBuffer, websocket.MessageBinary)
err, hisresponse = WsSend(ctx, conn, (*r).CarrierBuffer, websocket.MessageBinary)
default:
@ -102,11 +107,11 @@ func (r *GosmContainer) WsContainerSend(method WsCommunicationMethod, conn *webs
func (r *GosmContainer) WsContainerReceive(method WsCommunicationMethod, conn *websocket.Conn, ctx context.Context, dosth interface{}) (err error, myresponse interface{}, mtr websocket.MessageType) {
switch {
case method == ReceiveTextMethod || method == ReceiveBinaryMethod:
case method == TextMethod || method == BinaryMethod:
err, receiveval, myresponse, mtr = WsReceive(ctx, conn, dosth.(func([]byte) []byte))
(*r).CarrierBuffer = receiveval.([]byte)
(*r).ConvertBuffer2Json()
case method == ReceiveJsonMethod:
case method == JsonMethod:
err, receiveval, myresponse = WsjsonReceive(ctx, conn, dosth.(func(interface{}) interface{}))
mtr = websocket.MessageText
(*r).CarrierJson = receiveval.(CarrierJson)

Loading…
Cancel
Save