15/10/12 11:14
criscap85
Ciao da ore mi sto dannando per due cose:
1) Avere windows su questo imac invece che un computer decente e solo windows!
2) Come diavolo si fa a chiamare le funzioni esterne come InizializzaTapi??
Ecco a voi il codice!!!
Grazie a chi risponderà!
1) Avere windows su questo imac invece che un computer decente e solo windows!
2) Come diavolo si fa a chiamare le funzioni esterne come InizializzaTapi??
Ecco a voi il codice!!!
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Net; using System.Net.Sockets; using JulMar.Atapi; namespace ServerDiProva { public class Program { static void Main(string[] args) { try { IPAddress ipAd = IPAddress.Parse("127.0.0.1"); //use local m/c IP address, and use the same in the client /* Initializes the Listener */ TcpListener myList = new TcpListener(ipAd, 8586); /* Start Listeneting at the specified port */ myList.Start(); Console.WriteLine("Server Partito!"); Console.WriteLine("Porta utilizzata : 8586"); Console.WriteLine("In attesa di una connessione"); Socket s = myList.AcceptSocket(); Console.WriteLine("Client " + s.RemoteEndPoint.ToString() + " connesso!"); int esci = 0; while (esci == 0) { StringBuilder sb = new StringBuilder(); byte[] b = new byte[100]; int k = s.Receive(b); for (int i = 0; i < k; i++) sb.Append(Convert.ToChar(b[i]));//Console.Write(Convert.ToChar(b[i])); if (sb.ToString() == "sto cazzo") { ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("sta fica")); } if (sb.ToString() == "diocane") { ASCIIEncoding asen = new ASCIIEncoding(); s.Send(asen.GetBytes("vaffanculo!")); } } /* clean up */ s.Close(); myList.Stop(); } catch (Exception exc) { Console.WriteLine("Errore..... " + exc.StackTrace); } } private void InizializaTapi() { TapiManager _mgr = new TapiManager(""); if (_mgr.Initialize()) { foreach (TapiLine line in _mgr.Lines) { line.Changed += this.OnLineStateChanged; line.NewCall += this.OnNewCall; line.Ringing += this.OnRinging; line.CallInfoChanged += this.OnCallInfoChanged; // aggiunta adesso line.CallStateChanged += this.OnCallStateChanged; // aggiunta adesso line.Monitor(); } } } private void OnCallStateChanged(object sender, CallStateEventArgs e) { } private void OnCallInfoChanged(object sender, CallInfoChangeEventArgs e) { } private void OnLineStateChanged(object sender, LineInfoChangeEventArgs e) { } private void OnNewCall(object sender, NewCallEventArgs e) { } private void OnRinging(object sender, EventArgs e) { } } }
Grazie a chi risponderà!
aaa