2014-04-26 09:18:56 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  System  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-10-19 17:19:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
									
										
										
										
											2015-06-21 18:18:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"fmt" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-19 17:19:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/SommerEngineering/Ocean/ICCC" 
							 
						 
					
						
							
								
									
										
										
										
											2014-11-07 09:46:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/SommerEngineering/Ocean/ICCC/SystemMessages" 
							 
						 
					
						
							
								
									
										
										
										
											2014-10-19 17:19:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/SommerEngineering/Ocean/Log" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									LM  "github.com/SommerEngineering/Ocean/Log/Meta" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
									
										
										
										
											2014-04-26 09:18:56 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 15:44:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// The receiver function for the ICCC message, that a server is up and running.
  
						 
					
						
							
								
									
										
										
										
											2015-06-21 18:18:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  icccSystemStart ( data  map [ string ] [ ] string )  ( result  map [ string ] [ ] string )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Recover from errors:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									defer  func ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  :=  recover ( ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Log . LogFull ( senderName ,  LM . CategorySYSTEM ,  LM . LevelERROR ,  LM . SeverityUnknown ,  LM . ImpactUnknown ,  LM . MessageNamePARSE ,  fmt . Sprintf ( "Was not able to execute the ICCC server startup message. %s" ,  err ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											result  =  make ( map [ string ] [ ] string ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 15:44:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Converts the HTTP form data into an object:
 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-21 18:18:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									_ ,  _ ,  obj  :=  ICCC . Data2Message ( SystemMessages . ICCCStartUpMessage { } ,  data ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Was it possible to convert the data?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  obj  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Cast the object to the right type:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										messageData  :=  obj . ( SystemMessages . ICCCStartUpMessage ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Provide a log entry:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Log . LogShort ( senderName ,  LM . CategorySYSTEM ,  LM . LevelINFO ,  LM . MessageNameSTARTUP ,  ` ICCC message: The server is now up and ready. ` ,  messageData . PublicIPAddressAndPort ,  messageData . AdminIPAddressAndPort ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 15:44:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-21 18:18:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// An answer is necessary:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  ICCC . Message2Data ( "" ,  "" ,  SystemMessages . AnswerACK ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Log . LogShort ( senderName ,  LM . CategorySYSTEM ,  LM . LevelINFO ,  LM . MessageNameSTARTUP ,  ` ICCC message: Was not able to create the message. ` ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										fmt . Println ( ` [Error] ICCC message: Was not able to create the message. ` ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-06-17 15:44:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-06-21 18:18:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// In any other error case:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									result  =  make ( map [ string ] [ ] string ,  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return 
							 
						 
					
						
							
								
									
										
										
										
											2014-04-26 09:18:56 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}