Skip to content
Browse files

Version 0.5

  • Loading branch information...
1 parent 8da5fa5 commit 3a0cd9dc9a6d07185762041bde749ae33283731d asergey committed Jan 31, 2009
Showing with 142 additions and 0 deletions.
  1. +58 −0 lib/otp.net/OtpTest/OtpTest.csproj
  2. +84 −0 lib/otp.net/OtpTest/Test.cs
View
58 lib/otp.net/OtpTest/OtpTest.csproj
@@ -0,0 +1,58 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{51C10949-3327-4CE9-A4D0-58F1336284F4}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>ConsoleApplication1</RootNamespace>
+ <AssemblyName>ConsoleApplication1</AssemblyName>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>2.0</OldToolsVersion>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Test.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Otp\Otp.csproj">
+ <Project>{8155F56B-4925-406C-8619-7D0E57DD7FE1}</Project>
+ <Name>Otp</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
84 lib/otp.net/OtpTest/Test.cs
@@ -0,0 +1,84 @@
+using System;
+
+namespace Otp
+{
+ public class Test
+ {
+ static public void Main(String[] args)
+ {
+ System.Console.Out.WriteLine("Otp test...");
+
+ if (args.Length < 1)
+ {
+ System.Console.Out.WriteLine("Usage: Otp sname\n where sname is" +
+ "the short name of the Erlang node");
+ return;
+ }
+
+ OtpNode.useShortNames = true;
+
+ String host = System.Net.Dns.GetHostName();
+ String user = Environment.UserName;
+ OtpNode node = new OtpNode(user + "@" + host);
+ String remote = (args[0].Contains("@")) ? args[0] : remote = args[0] + "@" + host;
+ OtpMbox mbox = null;
+
+ System.Console.Out.WriteLine("This node is: {0} (cookie='{1}'). Remote: {2}",
+ node.node(), node.cookie(), remote);
+
+ //bool ok = node.ping(remote, 1000*300);
+
+ OtpCookedConnection conn = node.getConnection(remote);
+
+ try
+ {
+ if (conn != null)
+ System.Console.Out.WriteLine(" successfully pinged node " + remote + "\n");
+ else
+ throw new System.Exception("Could not ping node: " + remote);
+
+ conn.traceLevel = 1;
+
+ mbox = node.createMbox();
+ mbox.registerName("server");
+
+ mbox.sendRPC(conn.peer.node(), "lists", "reverse", new Erlang.List(new Erlang.String("Hello world!")));
+ Erlang.Object reply = mbox.receiveRPC(5000);
+ System.Console.Out.WriteLine("<= " + reply.ToString());
+
+ {
+ Erlang.List rpcArgs = new Erlang.List(
+ new Erlang.Object[] {
+ mbox.self(),
+ new Erlang.Tuple(
+ new Erlang.Object[] {
+ new Erlang.Atom("table"), new Erlang.Atom("test"), new Erlang.Atom("simple")
+ }
+ )
+ }
+ );
+
+ mbox.sendRPC(conn.peer.node(), "mnesia_subscr", "subscribe", rpcArgs);
+ reply = mbox.receiveRPC(5000);
+ System.Console.Out.WriteLine("<= " + reply.ToString());
+ }
+
+ while (true)
+ {
+ Erlang.Object msg = mbox.receive();
+ System.Console.Out.WriteLine("IN msg: " + msg.ToString() + "\n");
+ }
+ }
+ catch (System.Exception e)
+ {
+ System.Console.Out.WriteLine("Error: " + e.ToString());
+ }
+ finally
+ {
+ node.closeMbox(mbox);
+ }
+
+ node.close();
+ }
+ }
+}

0 comments on commit 3a0cd9d

Please sign in to comment.
Something went wrong with that request. Please try again.