Inheritance: IRpcHandler, IRpcSender
示例#1
0
    public static new SocialNode CreateNode() {

      SocialConfig social_config;
      NodeConfig node_config;
      IpopConfig ipop_config;
      RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

      if(File.Exists(CONFIGPATH)) {
        social_config = Utils.ReadConfig<SocialConfig>(CONFIGPATH);
      }
      else {
        social_config = SocialUtils.CreateConfig();
      }

      node_config = Utils.ReadConfig<NodeConfig>(social_config.BrunetConfig);
      ipop_config = Utils.ReadConfig<IpopConfig>(social_config.IpopConfig);

      if(!File.Exists(node_config.Security.KeyPath) || 
        node_config.NodeAddress == null) {
        node_config.NodeAddress = Utils.GenerateAHAddress().ToString();
        Utils.WriteConfig(social_config.BrunetConfig, node_config);

        SocialUtils.WriteToFile(rsa.ExportCspBlob(true), 
          node_config.Security.KeyPath);
      }
      else if(File.Exists(node_config.Security.KeyPath)) {
        rsa.ImportCspBlob(SocialUtils.ReadFileBytes(
          node_config.Security.KeyPath));
      }

      SocialNode node = new SocialNode(node_config, ipop_config, rsa);
#if !SVPN_NUNIT
      SocialDnsManager sdm = new SocialDnsManager(node);
      SocialStatsManager ssm = new SocialStatsManager(node);

      SocialConnectionManager manager = new SocialConnectionManager(node,
        node.AppNode.Node.Rpc, sdm, ssm, social_config);

      JabberNetwork jabber = new JabberNetwork(social_config.JabberID, 
        social_config.JabberPass, social_config.JabberHost, 
        social_config.JabberPort);

      TestNetwork test = new TestNetwork();

      manager.Register("jabber", jabber);
      manager.Register("test", test);

      if(social_config.AutoLogin) {
        manager.Login("jabber", social_config.JabberID, 
          social_config.JabberPass);
      }

      HttpInterface http = new HttpInterface(social_config.HttpPort);
      http.ProcessEvent += manager.ProcessHandler;

      node._marad.Resolver = sdm;
      node.Shutdown.OnExit += jabber.Logout;
      node.Shutdown.OnExit += http.Stop;
      http.Start();
#endif

      return node;
    }
示例#2
0
        public static new SocialNode CreateNode()
        {
            SocialConfig             social_config;
            NodeConfig               node_config;
            IpopConfig               ipop_config;
            RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

            if (File.Exists(CONFIGPATH))
            {
                social_config = Utils.ReadConfig <SocialConfig>(CONFIGPATH);
            }
            else
            {
                social_config = SocialUtils.CreateConfig();
            }

            node_config = Utils.ReadConfig <NodeConfig>(social_config.BrunetConfig);
            ipop_config = Utils.ReadConfig <IpopConfig>(social_config.IpopConfig);

            if (!File.Exists(node_config.Security.KeyPath) ||
                node_config.NodeAddress == null)
            {
                node_config.NodeAddress = Utils.GenerateAHAddress().ToString();
                Utils.WriteConfig(social_config.BrunetConfig, node_config);

                SocialUtils.WriteToFile(rsa.ExportCspBlob(true),
                                        node_config.Security.KeyPath);
            }
            else if (File.Exists(node_config.Security.KeyPath))
            {
                rsa.ImportCspBlob(SocialUtils.ReadFileBytes(
                                      node_config.Security.KeyPath));
            }

            SocialNode node = new SocialNode(node_config, ipop_config, rsa);

#if !SVPN_NUNIT
            SocialDnsManager   sdm = new SocialDnsManager(node);
            SocialStatsManager ssm = new SocialStatsManager(node);

            SocialConnectionManager manager = new SocialConnectionManager(node,
                                                                          node.AppNode.Node.Rpc, sdm, ssm, social_config);

            JabberNetwork jabber = new JabberNetwork(social_config.JabberID,
                                                     social_config.JabberPass, social_config.JabberHost,
                                                     social_config.JabberPort);

            TestNetwork test = new TestNetwork();

            manager.Register("jabber", jabber);
            manager.Register("test", test);

            if (social_config.AutoLogin)
            {
                manager.Login("jabber", social_config.JabberID,
                              social_config.JabberPass);
            }

            HttpInterface http = new HttpInterface(social_config.HttpPort);
            http.ProcessEvent += manager.ProcessHandler;

            node._marad.Resolver  = sdm;
            node.Shutdown.OnExit += jabber.Logout;
            node.Shutdown.OnExit += http.Stop;
            http.Start();
#endif

            return(node);
        }