Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void send(java.net.SocketAddress socketAddress, pspsharp.network.adhoc.AdhocMessage adhocMessage) throws java.io.IOException
        public override void send(SocketAddress socketAddress, AdhocMessage adhocMessage)
        {
            if (proOnline.isBroadcast(socketAddress))
            {
                int port = proOnline.getBroadcastPort(socketAddress);
                // Broadcast to all MAC's/IP's
                int numberMacIps = proOnline.NumberMacIps;
                for (int i = 0; i < numberMacIps; i++)
                {
                    MacIp macIp = proOnline.getMacIp(i);
                    if (macIp != null)
                    {
                        SocketAddress remoteSocketAddress = proOnline.getSocketAddress(macIp.mac, port);
                        //if (log.DebugEnabled)
                        {
                            Console.WriteLine(string.Format("Sending broadcasted message to {0}: {1}", macIp, adhocMessage));
                        }
                        base.send(remoteSocketAddress, adhocMessage);
                    }
                }
            }
            else
            {
                base.send(socketAddress, adhocMessage);
            }
        }
Ejemplo n.º 2
0
        protected internal virtual void addFriend(string nickName, pspNetMacAddress mac, int ip)
        {
            lock (this)
            {
                //if (log.DebugEnabled)
                {
                    Console.WriteLine(string.Format("Adding friend nickName='{0}', mac={1}, ip={2}", nickName, mac, convertIpToString(ip)));
                }

                Modules.sceNetAdhocctlModule.hleNetAdhocctlAddPeer(nickName, mac);
                if (chatGUI != null)
                {
                    chatGUI.updateMembers(Modules.sceNetAdhocctlModule.PeersNickName);
                }

                bool found = false;
                foreach (MacIp macIp in macIps)
                {
                    if (mac.Equals(macIp.mac))
                    {
                        macIp.Ip = ip;
                        found    = true;
                        break;
                    }
                }

                if (!found)
                {
                    MacIp macIp = new MacIp(mac.macAddress, ip);
                    macIps.Add(macIp);

                    portManager.addHost(convertIpToString(ip));
                }
            }
        }
Ejemplo n.º 3
0
        public virtual sbyte[] getMacAddress(InetAddress inetAddress)
        {
            MacIp macIp = getMacIp(inetAddress);

            if (macIp == null)
            {
                return(null);
            }

            return(macIp.mac);
        }
Ejemplo n.º 4
0
        public virtual int getIp(sbyte[] macAddress)
        {
            MacIp macIp = getMacIp(macAddress);

            if (macIp == null)
            {
                return(0);
            }

            return(macIp.ip);
        }
Ejemplo n.º 5
0
 protected internal virtual void deleteAllFriends()
 {
     lock (this)
     {
         while (macIps.Count > 0)
         {
             MacIp macIp = macIps[0];
             deleteFriend(macIp.ip);
         }
     }
 }
Ejemplo n.º 6
0
        public virtual InetAddress getInetAddress(sbyte[] macAddress)
        {
            if (sceNetAdhoc.isAnyMacAddress(macAddress))
            {
                return(broadcastInetAddress);
            }

            MacIp macIp = getMacIp(macAddress);

            if (macIp == null)
            {
                return(null);
            }

            return(macIp.inetAddress);
        }