示例#1
0
 public Interceptor(IProtocolAdapter adapter, Type protocol = null)
     : base(typeof(MarshalByRefObject))
 {
     if (adapter == null)
     {
         throw new ArgumentNullException(nameof(adapter));
     }
     _adapter  = adapter;
     _protocol = protocol;
 }
示例#2
0
 public static TProto P <TProto>(IProtocolAdapter adapter)
     where TProto : class
 {
     if (!typeof(TProto).IsInterface)
     {
         throw new NotSupportedException("Only protocol interfaces are supported");
     }
     return((TProto) new Interceptor(adapter, typeof(TProto))
            .GetTransparentProxy());
 }
 /// <summary>
 /// Ajoute un nouveau joueur
 /// </summary>
 /// <param name="iptable">La table des IP</param>
 /// <param name="ip">L'adresse IP</param>
 /// <param name="idspecy">La race jouée</param>
 /// <param name="pseudo">Le pseudo du joueur</param>
 public void AddPlayer(IProtocolAdapter ipa, Dictionary<String, int> iptable, String ip, uint idspecy, string pseudo)
 {
     Specy sp;
     switch(idspecy){
         case (uint)PlayerSpecy.ZERG :
         default :
             sp = new Specy("Zerg");
             break;
     }
     iptable.Add(ip, Server.components.Game.getInstance().AddPlayer(sp, pseudo));
     Protocol_handler ph = new Protocol_handler();
     int width = Server.components.Game.getInstance().getMapWidth();
     int height = Server.components.Game.getInstance().getMapHeight();
     ipa.send(ph.Identify_mapSize(width, height));
 }
 /// <summary>
 /// Envoie la position
 /// </summary>
 /// <param name="ipa">L'adaptateur réseau</param>
 /// <param name="pid">Le numéro du joueur</param>
 /// <param name="srcid">Le numéro de l'entité source</param>
 public void sendPosition(IProtocolAdapter ipa, int pid, int srcid)
 {
     lock (this)
     {
         Protocol_handler ph = new Protocol_handler();
         Point p = (Point)this.getPosition(pid, srcid);
         if (p == null)
         {
             throw new ConcreteEntitiesExistenceException();
         }
         ipa.send(ph.Unit_position(srcid, p));
     }
 }
 /// <summary>
 /// Envoie la liste des unités
 /// </summary>
 /// <param name="ipa"></param>
 public void sendAllUnits(IProtocolAdapter ipa)
 {
     Protocol_handler ph = new Protocol_handler();
     ipa.send(ph.Entity_sendlist(this.getAllUnits()));
 }
 /// <summary>
 /// retourne les informations sur l'entité
 /// </summary>
 /// <param name="IdEntity"> identifiant de l'entité</param>
 /// <returns>informations sur l'entité</returns>
 public void getInformationEntity(IProtocolAdapter ipa, int IdEntity)
 {
     Protocol_handler ph = new Protocol_handler();
     ipa.send(ph.Entity_sendinfo(
         Server.components.Game.getInstance().getInformationEntity(IdEntity)
     ));
 }
 /// <summary>
 /// retourne les informations du player
 /// le vespen
 /// le mineraux
 /// popmax
 /// pop
 /// </summary>
 /// <param name="IdPlayer">  identifiant du  player</param>
 public void getInfoPlayer(IProtocolAdapter ipa, int IdPlayer)
 {
     Protocol_handler ph = new Protocol_handler();
     ipa.send(ph.Player_sendressources(
         Server.components.Game.getInstance().getInfoPlayer(IdPlayer)
     ));
 }
示例#8
0
 public static TProto P <TProto>(this IProtocolAdapter adapter)
     where TProto : class
 {
     return(Protocol.P <TProto>(adapter));
 }
示例#9
0
 public static object P(this IProtocolAdapter adapter)
 {
     return(Protocol.P(adapter));
 }
示例#10
0
 public static object P(IProtocolAdapter adapter)
 {
     return(new Interceptor(adapter).GetTransparentProxy());
 }
示例#11
0
 public void Map <TMessage>(IProtocolAdapter adapter)
     where TMessage : IMessage
 {
     map.Add(typeof(TMessage), adapter);
 }