sockets en NS.
#17
tcl
namespace eval ::socks {
   variable aurore
 
#********************#
# Service.Socket 1.0 #
#********************#
 
#**************************#
# Information link reseau. #
#**************************#
 
set aurore(serv) "Aurore.****.fr"
set aurore(ip) "ip"
set aurore(port) "port"
set aurore(pwdlink) "pass"
set aurore(info) "Aurore Services"
 
#****************************#
# Configuration des sockets. #
#****************************#
 
set aurore(nick) "Hera"
set aurore(identd) "Hera"
set aurore(host) "Services.****.fr"
set aurore(nom) "Services-Log"
 
#***************************#
# Salon de log des sockets. #
#***************************#
 
set aurore(log) "#Services"
set aurore(quit01) "Redemarage Aurore-Service."
set aurore(quit02) "Fermeture Aurore-Service."
 
#****************************************#
# Lancement de la procédure des sockets. #
#****************************************#
 
proc checkconnect {} {
   if {![info exists aurore(idx)]} { utimer 30 [namespace current]::checkconnect } else { xconnect:serv }
}
 
proc xconnect:serv {} {
   variable aurore
   if [catch {set aurore(idx) [connect $aurore(ip) $aurore(port)]} err] {
      putlog "Connection error :$err"
      return
   }
   putdcc $aurore(idx) "PASS $aurore(pwdlink)"
   putdcc $aurore(idx) "SERVER $aurore(serv) 1 [unixtime] [unixtime] J09 ACAA\] +s :$aurore(info)"
   putdcc $aurore(idx) ":$aurore(serv) NICK $aurore(nick) '' '' $aurore(identd) $aurore(host) $aurore(serv) '' :$aurore(nom)"
   putdcc $aurore(idx) ":$aurore(nick) MODE $aurore(nick) +owsgkd"
   putdcc $aurore(idx) ":$aurore(nick) JOIN $aurore(log)"
   putdcc $aurore(idx) ":$aurore(nick) MODE $aurore(log) +ntsv $aurore(nick)"
   control $aurore(idx) [namespace current]::controling_server
   utimer 10 [namespace current]::verify
}
 
#***********************************#
# Verify si le serveur est Connecté #
#***********************************#
 
proc verify {} {
   variable aurore
   if [valididx [set [namespace current]::aurore(idx)]] {
      utimer 30 [namespace current]::verify
   } else {
      xconnect:serv
   }
}
 
proc controling_server {idx arg} {
   variable aurore
   set arg1 [lindex [split $arg " "] 0]
   set arg2 [lindex [split $arg " "] 1]
   set arg3 [lindex [split $arg " "] 2]
   set arg4 [lindex [split $arg " "] 3]
   set arg5 [lindex [split $arg " "] 4]
   set arg6 [lindex [split $arg " "] 5]
   set arg7 [lindex [split $arg " "] 6]
   set arg8 [lindex [split $arg " "] 7]
   set arg10 [string trim [lrange [split $arg " "] 3 end] :]
   if {$arg2=="PING"} {
      putdcc $aurore(idx) ":$aurore(serv) PONG $aurore(ip) :$aurore(serv)"
    }   
}
 
#**********************#
# Restart des sockets. #
#**********************#
 
bind evnt - prerestart [namespace current]::eva:restart
proc eva:restart {args} {
   variable aurore
   putdcc $aurore(idx) ":$aurore(serv) SQUIT $aurore(serv) :Restart Sockets."
   catch {close $aurore(idx)}
}
 
#********************#
# Rehash du Service. #
#********************#
 
bind dcc n xrehash [namespace current]::eggy:xrehash
proc eggy:xrehash {nick idx arg} {
   variable aurore
   putdcc $idx "\002Rehash de Aurore-Service et des fichiers\002"
   utimer 4 rehash
}
 
#*********************#
# Restart du Service. #
#*********************#
 
bind dcc n xrestart [namespace current]::eggy:xrestart
proc eggy:xrestart {nick idx arg} {
   variable aurore
   putdcc $idx "\002Redémarrage de Aurore-service\002"
   if [valididx [set [namespace current]::aurore(idx)]] {
      putdcc $aurore(idx) ":$aurore(nick) QUIT :$aurore(quit01)"
      putdcc $aurore(idx) ":$aurore(serv) SQUIT :$aurore(serv)"
      catch {close $aurore(idx)}
      foreach kill [utimers] {
          if {[lindex $kill 1]=="[namespace current]::verify"} { killutimer [lindex $kill 2] }
      }
    }
    xconnect:serv
}

#*****************#
# Die du Service. #
#*****************#
 
bind dcc n xdie [namespace current]::eggy:xdie
proc eggy:xdie {nick idx arg} {
    putdcc $idx "\002Arrêt de  Aurore-Service\002"
    if [valididx [set [namespace current]::aurore(idx)]] {
       putdcc $aurore(idx) ":$aurore(nick) QUIT : $aurore(quit02)"
       putdcc $aurore(idx) ":$aurore(serv) SQUIT :$aurore(quit02)"
       catch {close $aurore(idx)}
       foreach kill [utimers] {
          if {[lindex $kill 1]=="[namespace current]::verify"} { killutimer [lindex $kill 2] }
       }
   }
}
 
#****************************#
# Fin du Service Sockets 1.0 #
#****************************#
# connection 
[namespace current]::xconnect:serv
}
 
putlog "\0031Service Sockets 1.0 \0034Chargé."


C'est en reconnaissant ses erreurs que l'on progresse Wink
Répondre Avertir


Messages dans ce sujet
sockets en NS. - par aliasangelius - 11/05/2011, 16:57
RE: sockets en NS. - par CrazyCat - 11/05/2011, 17:30
RE: sockets en NS. - par aliasangelius - 11/05/2011, 17:32
RE: sockets en NS. - par djkenny - 11/05/2011, 18:11
RE: sockets en NS. - par aliasangelius - 11/05/2011, 18:28
RE: sockets en NS. - par djkenny - 11/05/2011, 18:42
RE: sockets en NS. - par djkenny - 11/05/2011, 18:46
RE: sockets en NS. - par djkenny - 11/05/2011, 18:50
RE: sockets en NS. - par aliasangelius - 11/05/2011, 19:46
RE: sockets en NS. - par djkenny - 12/05/2011, 17:50
RE: sockets en NS. - par aliasangelius - 12/05/2011, 20:04
RE: sockets en NS. - par djkenny - 13/05/2011, 06:04
RE: sockets en NS. - par djkenny - 13/05/2011, 06:15
RE: sockets en NS. - par CrazyCat - 13/05/2011, 08:59
RE: sockets en NS. - par djkenny - 13/05/2011, 13:03
RE: sockets en NS. - par aliasangelius - 13/05/2011, 16:34
RE: sockets en NS. - par djkenny - 13/05/2011, 20:31
RE: sockets en NS. - par aliasangelius - 14/05/2011, 11:38
RE: sockets en NS. - par djkenny - 14/05/2011, 13:08
RE: sockets en NS. - par aliasangelius - 14/05/2011, 13:41

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté