2014-04-26 09:18:56 +00:00
package ICCC
2014-10-19 17:19:11 +00:00
import (
"github.com/SommerEngineering/Ocean/ICCC/Scheme"
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"github.com/SommerEngineering/Ocean/Tools"
"net/http"
"net/url"
)
2014-04-26 09:18:56 +00:00
2015-06-17 15:44:52 +00:00
// Send a message to a listener.
2014-04-26 09:18:56 +00:00
func sendMessage ( listener Scheme . Listener , data map [ string ] [ ] string ) {
2015-06-17 15:44:52 +00:00
// Convert the data and encode it:
2014-04-26 09:18:56 +00:00
valuesHTTP := url . Values ( data )
2015-06-17 15:44:52 +00:00
// Add the communication password:
2014-04-26 09:18:56 +00:00
valuesHTTP . Add ( ` InternalCommPassword ` , Tools . InternalCommPassword ( ) )
2015-06-17 15:44:52 +00:00
// Try to deliver the message:
2014-04-26 09:18:56 +00:00
if _ , err := http . PostForm ( ` http:// ` + listener . IPAddressPort + ` /ICCC ` , valuesHTTP ) ; err != nil {
2015-06-17 15:44:52 +00:00
// Case: Was not possible to deliver.
2014-04-26 09:18:56 +00:00
Log . LogFull ( senderName , LM . CategorySYSTEM , LM . LevelERROR , LM . SeverityCritical , LM . ImpactUnknown , LM . MessageNameNETWORK , ` Was not able to send the ICCC message. ` , err . Error ( ) )
}
return
}