forked from zeroc-ice/ice-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClient.php
133 lines (119 loc) · 3.46 KB
/
Client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<HTML>
<HEAD>
<TITLE>Hello Demo</TITLE>
</HEAD>
<BODY>
<H1>Hello Demo</H1>
<?php
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
//
// Enable error reporting
//
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require_once 'Ice.php';
require_once 'Hello.php';
$communicator = Ice\initialize();
//
// Change this to true if SSL is configured for the PHP extension.
//
$have_ssl = false;
if(isset($_POST["submitted"]))
{
echo "<HR>\n";
echo "<P>Status:<BR><B>\n";
try
{
if($have_ssl)
{
$p = $communicator->stringToProxy("hello:tcp -h localhost -p 10000:udp -h localhost -p 10000:ssl -h localhost -p 10001");
}
else
{
$p = $communicator->stringToProxy("hello:tcp -h localhost -p 10000:udp -h localhost -p 10000");
}
if(isset($_POST["mode"]))
{
if($_POST["mode"] == "oneway")
{
$p = $p->ice_oneway();
}
elseif($_POST["mode"] == "datagram")
{
$p = $p->ice_datagram();
}
}
$delay = 0;
if(isset($_POST["secure"]) and $_POST["secure"] == "yes")
{
$p = $p->ice_secure(true);
}
if(isset($_POST["timeout"]) and $_POST["timeout"] == "yes")
{
$p = $p->ice_invocationTimeout(2000);
}
if(isset($_POST["delay"]) and $_POST["delay"] == "yes")
{
$delay = 2500;
}
if($p->ice_isTwoway())
{
$hello = Demo\HelloPrxHelper::checkedCast($p);
}
else
{
$hello = Demo\HelloPrxHelper::uncheckedCast($p);
}
if(isset($_POST["sayHello"]))
{
$hello->sayHello($delay);
}
elseif(isset($_POST["shutdown"]))
{
$hello->shutdown();
}
echo "OK\n";
}
catch(Ice\LocalException $ex)
{
echo "<pre>\n";
print_r($ex);
echo "</pre>\n";
}
echo "</B></P>\n";
echo "<HR>\n";
}
?>
<P>
<FORM method="POST" action="<?php echo basename($_SERVER["PHP_SELF"]); ?>">
<P>Mode:
<INPUT type="radio" name="mode" value="twoway"
<?php if(!isset($_POST["mode"]) or $_POST["mode"] == "twoway") echo " checked "; ?>
> Twoway
<INPUT type="radio" name="mode" value="oneway"
<?php if(isset($_POST["mode"]) and $_POST["mode"] == "oneway") echo " checked "; ?>
> Oneway
<INPUT type="radio" name="mode" value="datagram"
<?php if(isset($_POST["mode"]) and $_POST["mode"] == "datagram") echo " checked "; ?>
> Datagram
</P>
<P>Options:
<INPUT type="checkbox" name="secure" value="yes"
<?php if(isset($_POST["secure"]) and $_POST["secure"] == "yes") echo " checked "; ?>
<?php if(!$have_ssl) echo " disabled "; ?>
> Secure
<INPUT type="checkbox" name="timeout" value="yes"
<?php if(isset($_POST["timeout"]) and $_POST["timeout"] == "yes") echo " checked "; ?>
> Timeout
<INPUT type="checkbox" name="delay" value="yes"
<?php if(isset($_POST["delay"]) and $_POST["delay"] == "yes") echo " checked "; ?>
> Delay
</P>
<P>
<INPUT type="hidden" name="submitted" value="yes">
<INPUT type="submit" name="sayHello" value="Say Hello">
<INPUT type="submit" name="shutdown" value="Shutdown">
</FORM>
</BODY>
</HTML>