Afyn
Messages postés608Date d'inscriptionsamedi 3 août 2002StatutMembreDernière intervention22 décembre 2016
-
30 juin 2010 à 11:11
Afyn
Messages postés608Date d'inscriptionsamedi 3 août 2002StatutMembreDernière intervention22 décembre 2016
-
30 juin 2010 à 12:20
Introduction
Silverlight tourne coté client(Win/Mac/MoonLight)
Il suffit de copier les fichiers sur l'hébergement LAMP
Communication use HTTP protocol.
<?php
session_start();
// ouvrir le dosssier msg
$dossier = opendir('msg');
while ($fichier = readdir($dossier))
{
if (!preg_match("#^[.]{1,2}[a-z0-9 -.]*#i",$fichier))
{
$files_array[] = $fichier;
}
}
closedir($dossier);
sort($files_array);
foreach ($files_array as $key => $val)
{
if ($_SESSION['last_msg_ts'] < $val)
{
// Lit le message non lu
readfile('msg/'.$val,'r');
// Indique le dernier message lu
$_SESSION['last_msg_ts'] = $val;
exit;
}
}
?>
Poster un message avec WebClient
Private Sub SendMsg(ByVal Data As String)
ReadMsgTmr.Stop()
Try
Dim Client As New WebClient()
Client.Headers("Content-Type") = "application/x-www-form-urlencoded"
AddHandler Client.UploadStringCompleted, AddressOf SendMsgCompleted
Client.UploadStringAsync(New Uri(String.Format("{0}/write_msg.php", BASEPATH)), "Post",
"user= " & UsrTbx.Text & "&data=" & Data)
Catch ex As Exception
End Try
End Sub
Private Sub SendMsgCompleted(ByVal sender As Object, _
ByVal e As UploadStringCompletedEventArgs)
Try
Dim Msg As String = e.Result
Select Case Msg
Case Nothing
ReadMsgTmr.Interval = System.TimeSpan.FromMilliseconds(1)
ReadMsgTmr.Start()
Exit Sub
Case "0"
ReadMsgTmr.Interval = System.TimeSpan.FromMilliseconds(1)
ReadMsgTmr.Start()
End Select
Catch ex As Exception
End Try
End Sub
Lire un message avec WebClient
Private Sub ReadMsgTmr_Tick(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ReadMsgTmr.Tick
ReadMsgTmr.Stop()
Try
Dim Client = New WebClient
AddHandler Client.DownloadStringCompleted, AddressOf ReadMsgComplete
Client.DownloadStringAsync(New Uri(Config.BASEPATH & "/read_msg.php", UriKind.Absolute), 0)
Client = Nothing
Catch ex As Exception
'HtmlPage.Window.Alert(ex.Message)
End Try
End Sub
Private Sub ReadMsgComplete(ByVal sender As Object, _
ByVal e As DownloadStringCompletedEventArgs)
Try
' Si il y a un message
Dim Msg As String = e.Result
If Msg <> "" Then
DisplayTextinChatBox(Msg)
' raffale
ReadMsgTmr.Interval = System.TimeSpan.FromMilliseconds(150)
Else
' idle
ReadMsgTmr.Interval = System.TimeSpan.FromMilliseconds(1500)
End If
Catch ex As Exception
End Try
ReadMsgTmr.Start()
End Sub
Deployement
Copié/collé les fichiers sur votre hébergement. Réglez CHMOD à 777
Mayzz
Messages postés2813Date d'inscriptionmardi 15 avril 2003StatutMembreDernière intervention 2 juin 202028 30 juin 2010 à 12:18
Afyn, il y a un emplacement spécifique ici pour cela, tu peux déposer tout ca dans la partie tutoriaux du site. Le forum est réservé pour les questions et l'aide en générale.
Si le déboguage est l'art d'enlever les bogues, la programmation doit être l'art de les créer.