Session management in Blackberry Webworks - blackberry

I want to be develop a blackberry application.That used an external DB through webservice call.I am choosing blackberry web works for developing this.I want to store a userid in phone like session after logged in a user.How use session management in BB webworks?
help is highly appreciated.
Thanks,
Comp

You can use either SQLlite or Cookies. Cookies are extremly useful and easy to implement for non critical data:
function setCookie(c_name,value,exdays){
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
try{
document.cookie=c_name + "=" + c_value;
}catch(e){
alert('exception: ' + e.name + '; ' + e.message);
}
}
function getCookie(c_name){
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name)
{
return unescape(y);
}
}
}
Good luck!

Related

How to Configure Jenkins Login in iPad using Unity

I had installed Jenkins in network and making build successfully.
I want to have authentication for my iPad app, developed with unity. I searched the plugin respective to this, but i can't find it. whether this can be attained by means of plugin or otherways?
As i need to login into my jenkins and afterward use the data of pipelines and all in my app accessed through URL so need login first.
Please do let me know the ways to do. Thanks in advance
After some searching and all i found the solution for this and i used following code to check authentication.
public void TryLogin ()
{
UnityWebRequest req = UnityWebRequest.Get ("Your jenkins login url of network");
req.method = "GET";
req.SetRequestHeader("Authorization", "Basic " + Convert.ToBase64String (Encoding.UTF8.GetBytes ("jenkinsId:jenkinsPassword")));
StartCoroutine (WaitForLoginRequest (req));
}
IEnumerator WaitForLoginRequest(UnityWebRequest req)
{
yield return req.Send ();
if (req.isError)
{
Debug.Log ("WWW Error: " + req.error);
}
else
{
Debug.Log("WWW Ok!:");
string response = Encoding.UTF8.GetString (req.downloadHandler.data);
Debug.Log ("Response code = " + req.responseCode);
Debug.Log ("String = " + response);
}
}
And check the response code for authentication.

Phonegap redirect to website and set cookies for it

I have IOS app based on phonegap, I want to redirect it to responsive website and set cookies to still logged in with his credentials.
windows.location is not work
Thanks
use "window.location.href"
window.location.href = "your website url here"
it will solve the problem on iOS
I found the solution
function scripting() {
ref.executeScript({
code: 'document.cookie = "token=' + res.data.token + '"; window.location= "' + res.redirectUrl + '"; '
}, function () {
ref.removeEventListener('loadstart', scripting);
});
}
var ref = cordova.InAppBrowser.open(res.redirectUrl, '_blank', 'location=no,toolbar=no');
ref.addEventListener('loadstart', scripting);
I hope it helps who had the same problem

Arabic input fields in unity

Is there is a way to change the language of input fields in unity to Arabic?. I tried ArabicSupport and it displayed Arabic correctly but using it with input fields didn't work because
GameObject.Find("input_field")
.GetComponent<InputField>().text = Fix3dTextCS.fix(
GameObject.Find("input_field").GetComponent<InputField>().text
);
caused an error so, if I printed the input text elsewhere, it will appear correctly but how can I do it with the same input field?
input field is a little bit tricky to let it work with Arabic Support
please try this opensource asset it has an prefab for Arabic Input Field and some other UIs.
OpenSource for ArabicSupport Solution Link
OpenSource for unity asset UI Arabic Support: Link
Have you tried adding arabic font in that input.
If so, post the error message it may help to find the bug
Using Font won't help because it will only change the theme of your current Input usage but not how you use to input in the Device.
You will need to use Input.Location <- Input is static so you can access it anywhere. The only problem is, I am not sure what is the exact variable for arabic is. My best guess is Input.Location = "Arabic" or "arabic".
If you want to automatically detect their location, the GPS which will unity3d turn on by calling Input.Location.Start, and turn off by Input.Location.Stop()
Here is a sample code for you.
using UnityEngine;
using System.Collections;
public class TestLocationService : MonoBehaviour
{
IEnumerator Start()
{
// First, check if user has location service enabled
if (!Input.location.isEnabledByUser) yield break;
// Start service before querying location
Input.location.Start();
// Wait until service initializes
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
yield return new WaitForSeconds(1);
maxWait--;
}
// Service didn't initialize in 20 seconds
if (maxWait < 1)
{
print("Timed out");
yield break;
}
// Connection has failed
if (Input.location.status == LocationServiceStatus.Failed)
{
print("Unable to determine device location");
yield break;
}
else
{
// Access granted and location value could be retrieved
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
}
// Stop service if there is no need to query location updates continuously
Input.location.Stop();
}
}

HTTP Live Streaming Service like LiveStream/Ustream/Twitch/Youtube Live

I'm new to live streaming and it's quite hard to find good information for beginners. Could anyone recommend resources to HLS besides Apple's documentation?
I'm trying to make an app similar to LiveStream where videos can be broadcasted to multiple users in real-time.
I've run into some services like encoding.com, heywatchencoding.com, and wowza, but I'm having difficulties with what each platform provides as the documentations for each seem to be for more intermediate/experienced users.
How difficult is it to create a more simple site like LiveStream/Ustream/Twitch/Youtube live? I'm trying to start simple with ios devices and the web, but it's harder to look for online resources. Any tips are helpful
By any chance, do anyone of you guys also know if I can use wowza with Parse.com services?
Thanks
Here is a very simple Node.js media server which spins up a HTTP server to stream most any video or audio format file from server to browser . Once you have nodejs installed just execute
node file_containing_below_code.js
then point your browser at URL
http://localhost:8888/
Your browser has baked in a slider widget for forward/reverse which auto sends traffic back to this server to respond in kind
enjoy ... btw no doc required just point and shoot
var http = require('http'),
fs = require('fs'),
util = require('util');
var path = "/path/to/audio/or/video/file/local/to/server/cool.mp4"; // put any audio or video file here
var port = 8888;
var host = "localhost";
http.createServer(function (req, res) {
var stat = fs.statSync(path);
var total = stat.size;
if (req.headers.range) { // meaning client (browser) has moved the forward/back slider
// which has sent this request back to this server logic ... cool
var range = req.headers.range;
var parts = range.replace(/bytes=/, "").split("-");
var partialstart = parts[0];
var partialend = parts[1];
var start = parseInt(partialstart, 10);
var end = partialend ? parseInt(partialend, 10) : total-1;
var chunksize = (end-start)+1;
console.log('RANGE: ' + start + ' - ' + end + ' = ' + chunksize);
var file = fs.createReadStream(path, {start: start, end: end});
res.writeHead(206, { 'Content-Range': 'bytes ' + start + '-' + end + '/' + total, 'Accept-Ranges': 'bytes', 'Content-Length': chunksize, 'Content-Type': 'video/mp4' });
file.pipe(res);
} else {
console.log('ALL: ' + total);
res.writeHead(200, { 'Content-Length': total, 'Content-Type': 'video/mp4' });
fs.createReadStream(path).pipe(res);
}
}).listen(port, host);
console.log("Server running at http://" + host + ":" + port + "/");

Titanium Studio to Grails imge post

I am trying to POST an image to my grails application and I'm not having much luck.
My titanium code is:
function upload(){
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e){
Ti.API.info(picMedia + " : " +message.value);
Ti.API.info('IN ERROR ' + e.error);
alert('Sorry, we could not upload your photo! Please try again.');
};
xhr.onload = function(){
Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + this.readyState);
};
xhr.onsendstream = function(e){
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
};
// open the client
xhr.open('POST', 'http://localhost:8080/FYP/Profile/appUploader');
// send the data
xhr.send({
media: picMedia,
message: message.value,
});
}
My grails code is as follows:
def appUploader(){
println "MEDAI PARAMS: " + params.media
def f = request.getFile('media') ;
println "HERE: " + f
if (request.getFile(params.media).getOriginalFilename()) {
println "FROM APP: " + request.getFile('myFile').getOriginalFilename()
return
}
}
Im getting error from the mobile app and error on the "if" line in the web app.
What am i doing wrong?
we had the same problem in one of our apps. The difficulty is that titanium is not really able to handle binary files in that case.
We did the following:
create base64 encoded string of the image on client side
post this string to the backend
decode base64 to image again
We analyzed a lot of network traffic and in most cases titanium tries to send the file but due to javascript its alway converted into some kind of ascii and this is not usable by the server side.

Resources