hi. i am korea student
today i relly confused with this question.
this program is chat program with wcf+p2p
using System
using System.Collections.Generic
using System.ComponentModel
using System.Data
using System.Drawing
using System.Linq
using System.Text
using System.Windows.Forms
using System.ServiceModel
namespace WinChatForm
{
[ServiceContract]
interface IQuickP2PChat
{
[OperationContract(IsOneWay = true)]
void Join(string nickname)
[OperationContract(IsOneWay = true)]
void SendMessage(string nickname, string msgbox)
[OperationContract(IsOneWay = true)]
void Leave(string nickname)
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public partial class Main : Form, IQuickP2PChat
{
ServiceHost _host
IQuickP2PChat _proxy
string _nickname
ChannelFactory<IQuickP2PChat> factory
public Main()
{
InitializeComponent()
}
private void InitHost()
{
_host = new ServiceHost(this)
_host.Open()
factory = new ChannelFactory<IQuickP2PChat>("QuickP2PChatEndpoint")
_proxy = factory.CreateChannel()
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (_proxy != null)
{
factory.Close()
}
if (_host != null && _host.State != CommunicationState.Closed)
{
_host.Close()
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
button1.Enabled = false
}
else
{
button1.Enabled = true
}
}
private void button1_Click(object sender, EventArgs e)
{
InitHost()
_nickname = textBox1.Text
_proxy.Join(_nickname)
panel1.Enabled = true
textBox1.Text = ""
textBox1.Enabled = false
}
private void btnInputMsg_Click(object sender, EventArgs e)
{
string temp = txtInputMsg.Text + Environment.NewLine
_proxy.SendMessage(_nickname,temp)
txtInputMsg.Clear()
}
private void btnExit_Click(object sender, EventArgs e)
{
_proxy.Leave(_nickname)
this.Close()
}
void IQuickP2PChat.Join(string nickname)
{
txtShow.Text += nickname + "Joined!!" + Environment.NewLine
lstUser.Items.Add(nickname)
}
void IQuickP2PChat.SendMessage(string nickname, string msgbox)
{
txtShow.Text = "[" + nickname + "]" + " " + msgbox
}
void IQuickP2PChat.Leave(string nickname)
{
txtShow.Text = nickname + "Leaved!!" + Environment.NewLine
lstUser.Items.Remove(nickname)
}
}
}
app.config
="1.0"="utf-8"
<configuration>
<system.serviceModel>
<bindings>
<netPeerTcpBinding>
<binding name="BindingUnsecure">
<security mode="None"/>
<resolver mode="Pnrp"/>
</binding>
</netPeerTcpBinding>
</bindings>
<services>
<service name="WinChatForm.Main">
<host>
<baseAddresses>
<add baseAddress="net.p2p://QuickP2PChat"/>
</baseAddresses>
</host>
<endpoint
contract="WinChatForm.IQuickP2PChat"
address=""
binding="netPeerTcpBinding"
bindingConfiguration="BindingUnsecure"
/>
</service>
</services>
<client>
<endpoint
name="QuickP2PChatEndpoint"
address="net.p2p://QuickP2PChatChat"
binding="netPeerTcpBinding"
bindingConfiguration="BindingUnsecure"
contract="WinChatForm.IQuickP2PChat"
/>
</client>
</system.serviceModel>
</configuration>
i relly need to this program working well....
someone help me? X|
1st fix version : i got some code at msdn the original form
version working well, but my custom version does not work
no compile error and exe error